我有一个在 Ubuntu Server 14.04 上的 Lamp Server 上运行的 WordPress 网站。我只是尝试使用永久链接选项Post Name,现在我的页面不再加载。
我打开mod_rewriteApache服务器的功能,重新启动,还是不行。
另外,这是我的.htaccess文件:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Run Code Online (Sandbox Code Playgroud)
请注意,文件夹的内容/wordpress已直接放入其中,/html
假设我的网站名称是mywebsite.com。
我怎样才能让它发挥作用?
编辑:这是我的/etc/apache2/sites-available/000-default.conf文件
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is …Run Code Online (Sandbox Code Playgroud) 我正在尝试重新定义默认帖子类型“POST”的属性。我正在尝试使用函数register_post_type_args。
我想将帖子类型的标签从“文章”重新定义为“博客”,并且我想在他的网址( mysite/blog/ my-post)中添加此帖子类型的标题“博客”
这是他在functions.php中的调用:
function post_to_blog ($args, $post_type) {
if ('post' !== $post_type) {
return $args;
}
$args ['label'] = 'Blog';
$args ['rewrite'] = array ('slug' => "blog", 'with_front' => true);
return $args;
}
add_filter ('register_post_type_args', 'post_to_blog', 1, 2);
Run Code Online (Sandbox Code Playgroud)
标签属性已正确重新定义。标签在后台更改。但没有考虑后段。我的帖子的网址仍然是mysite/name-of-post而不是mysite/blog/name-of-post
(我无法在设置/永久链接中添加 slug,因为我需要保留其他帖子类型的默认 url 类型)。
我想我用register_post_type_args来做,但我不明白为什么不考虑 slug 。你有解释吗?
编辑 :
出于好奇,我尝试使用register_post_type重新定义帖子。这不是正确的方法,但通过此解决方案,可以正确地重新定义 URL。
register_post_type( 'post', array(
'label' => 'Blog',
'rewrite' => array('slug' => "blog/", 'with_front' => true),
));
Run Code Online (Sandbox Code Playgroud) 您认为在Rails中创建SEO友好URL(动态)的最佳方法是什么?
我正试图在我的django应用程序中添加slug到url,就像SO一样.
目前,我的网页可以正常使用这样的网址:
http://example.com/foo/123/
Run Code Online (Sandbox Code Playgroud)
我想像这样添加'slugified'网址:
http://example.com/foo/123/foo-name-here
Run Code Online (Sandbox Code Playgroud)
通过简单地修改urlconf并向view函数添加一次性值,我可以让它工作得很好:
#urls.py
ulpatterns = patterns('project.app.views',
url(r'^foo/(?P<foo_id>\d+)/(?P<name_slug>\w+)/$', 'foo_detail', name='foo_detail'),
)
#views.py:
def foo_detail(request, foo_id, name_slug):
# stuff here, name slug is just discarded
Run Code Online (Sandbox Code Playgroud)
用slug visting url工作得很好.
但是,我的问题是我正在使用的时候@models.permalink.
对于我的Foo模型,我曾经有以下,它工作得很好:
@models.permalink
def get_absolute_url(self):
return ('foo_detail', [str(self.id),])
Run Code Online (Sandbox Code Playgroud)
但是,在我更改之后,每当我调用{{ foo.get_absolute_url }}模板时,结果总是一个空字符串.
我尝试了以下两个替换get_absolute_url,但两个都没有工作:
from django.template.defaultfilters import slugify
# attempt 1
@models.permalink
def get_absolute_url(self):
return ('foo_detail', [str(self.id), slugify(self.name)])
# attempt 2
@models.permalink
def get_absolute_url(self):
return ('foo_detail', (), {
'foo_id': str(self.id),
'name_slug': slugify(self.name),
})
Run Code Online (Sandbox Code Playgroud)
请注意,如果我 …
有谁知道如何修改 Wordpress 规范链接以添加自定义 URL 参数?
我有一个 Wordpress 站点,其页面可以查询单独的(非 Wordpress)数据库。我传递了 URL 参数“pubID”来显示个别书籍,它工作正常。
示例:http : //www.uglyducklingpresse.org/catalog/browse/item/?pubID=63
但是各个书页在 Google 中没有正确显示 - ?pubID 参数被删除了。
我想这可能是因为所有项目页面在源代码中都有相同的自动生成的“规范”URL 链接标签——其中一个“pubID”参数被删除了。
示例:链接 rel='canonical' href=' http://www.uglyducklingpresse.org/catalog/browse/item/ '
有没有办法编辑 .htaccess 以将自定义 URL 参数添加到 Wordpress,以便永久链接和“规范”链接不会删除该参数?
或者也许有另一种解决方案......感谢您的任何想法!
我在WordPress中更改了我的永久链接结构.
插件可以帮助我将旧链接重定向到新链接吗?
谢谢!
我网站上的每篇博文(http://www.correlated.org)都以自己的固定URL存档.
在每个存档页面上,我不仅要显示已存档的帖子,还要显示之前发布的10个帖子,这样人们就可以更好地了解博客提供的内容类型.
我担心的是谷歌和其他搜索引擎会认为其他帖子是重复内容,因为每个帖子都会出现在多个页面上.
在我的另一个博客 - http://coding.pressbin.com - 我试图通过加载早期的帖子作为AJAX调用来解决这个问题,但我想知道是否有更简单的方法.
有没有办法向搜索引擎发出信号,表明页面的特定部分不应被编入索引?
如果没有,是否有一种比AJAX调用更简单的方法来做我想做的事情?
我正在阅读django dev文档.这里说它不再推荐永久链接装饰器,在你的get_absolute_url方法中使用反向为模型实例生成完整的URL(滚动一点上面并查看警告框).
我认为它违反DRY,我们必须在每次需要时使用反向.那么使用固定链接有什么问题?为什么不再推荐?
在运行Nginx和WP并设置相当永久链接时遇到500问题.我一直在尝试谷歌的一些不同的方法,但似乎没有任何帮助.
配置 -
server {
listen 80;
root /var/www/mydomain.com/public_html;
index index.php index.html index.htm;
server_name .mydomain.com;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}
Run Code Online (Sandbox Code Playgroud)
所有文件都可以很好地加载,如果使用默认的永久链接设置,则页面可以正常工作.奇怪的是,如果我检查网络日志我首先看到200 OK正在收到,然后立即跟着500.任何想法?
编辑:设置关闭,因为我转而使用Apache.将标记正确答案,因为它似乎帮助了其他人.
我在带有 IIS7 的 Windows 服务器上托管了一个阿拉伯语 WordPress 站点(我无法迁移到 Linux 托管)。我试图将 WordPress 中的永久链接设置更改为:/%postname%/
但是,当我访问任何文章时,例如:http : //www.example.com/?????/我被重定向到主页,类别和标签也会发生同样的事情。
除了 web.config(我在共享主机上)之外,我无权访问 IIS 设置。这是我的 web.config 设置:
<rule name="wordpress" patternSyntax="Wildcard">
<match url="*" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="index.php" />
</rule>
Run Code Online (Sandbox Code Playgroud)
我在 PHP 5.5 上运行。