这个特定的代码工作在一台服务器上,而不是另一台服务器上。工作的一个有Apache2,另一个有Apache1。我怎样才能让这两种方法都奏效呢?
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
# SEO translation
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(?:[a-z]{2}/)?.*-p-([0-9]+)$ page.php?page_id=$1&%{QUERY_STRING}
RewriteRule ^(?:[a-z]{2}/)?(.*) $1?%{QUERY_STRING}
</IfModule>输入URL选项:
发布于 2012-10-04 00:41:14
它出现了?:在apache1中不是有效的regexp。回避它可以解决问题。
发布于 2012-09-19 17:06:38
试着复制条件。它们只适用于紧跟RewriteRule的单条,因此您需要对这两条规则进行复制:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/?(?:[a-z]{2}/)?.*-p-([0-9]+)$ page.php?page_id=$1 [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/?(?:[a-z]{2}/)?(.*) $1 [L,QSA]还使前面的斜杠是可选的(/?)。
https://stackoverflow.com/questions/12499500
复制相似问题