我正在我的网站上工作,我创建了一些新的网页来解释我的网站的更多细节。现在,为了搜索引擎优化的目的,我知道谷歌更喜欢包含关键字的链接。所以我做的页面可以被称为新鞋。现在,我已经将页面设置为website.com/newshoes,但由于google可能会将其视为一个单词,所以我正在努力使其显示website.com/new-shoes,而不是使用htaccess,但我无法使其正常工作。这就是我想出来的,但它不起作用。
RewriteRule ^([^/]*)-([^/]*)$ /index.php?$1$2 [QSA,L]所以有人能帮我吗。谢谢!
编辑
RewriteEngine On
RewriteCond %{HTTP_HOST} ^reflap\.com [NC]
RewriteRule (.*) http://www.reflap.com/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]*)$ /index.php?$1 [QSA,L]
RewriteRule ^([^/]*)/$ /index.php?$1 [QSA,L]
RewriteRule ^([^/]*)/([^/]*)$ /index.php?$1&$2 [QSA,L]
RewriteRule ^([^/]*)/([^/]*)/$ /index.php?$1&$2 [QSA,L]
RewriteRule ^/facebook-chat/ http://chat.facebook.com/ [P]
ErrorDocument 404 /error.php发布于 2013-05-23 15:03:13
RewriteEngine On
RewriteRule ^([^/]*)-([^/]*)$ /index.php?$1$2
RewriteCond %{HTTP_HOST} ^reflap\.com [NC]
RewriteRule (.*) http://www.reflap.com/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]*)/?$ /index.php?$1 [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]*)/([^/]*)/?$ /index.php?$1&$2 [QSA,L]
RewriteRule ^/facebook-chat/ http://chat.facebook.com/ [P]
ErrorDocument 404 /error.php发布于 2013-05-23 14:14:59
您需要将重写规则中的细节放在泛型之上-您的排序意味着您将被重定向到index.php?new-page,因为您首先要匹配一个更通用的模式。
试试这个:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^reflap\.com [NC]
RewriteRule (.*) http://www.reflap.com/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]*)-([^/]*)$ /index.php?$1$2 [QSA,L]
RewriteRule ^([^/]*)/([^/]*)$ /index.php?$1&$2 [QSA,L]
RewriteRule ^([^/]*)/([^/]*)/$ /index.php?$1&$2 [QSA,L]
RewriteRule ^/facebook-chat/ http://chat.facebook.com/ [P]
RewriteRule ^([^/]*)$ /index.php?$1 [QSA,L]
RewriteRule ^([^/]*)/$ /index.php?$1 [QSA,L]
ErrorDocument 404 /error.php这应该可以解决您的问题--但是在这个.htaccess中有一个更普遍的问题-- RewriteCond指令只适用于紧随其后的RewriteRule。他们不会继续遵循任何其他规则。这意味着,无论文件或目录是否确实存在,第一个规则之后的所有规则都将适用。
http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html#rewritecond
https://stackoverflow.com/questions/16705484
复制相似问题