在我的htaccess我有mod_rewrite的重写所有的index.php,但
RewriteRule ^([^/]+)/?$ cms.php?seotitle=$1 [L]
的想法是,index.html的将加载罚款,然后在domain.com/anythinghere.html要求任何事情都会使用规则从cms.php抓取文件。
然而它不工作 - 任何线索?真的需要这种排序尽快。
在我的htaccess我有mod_rewrite的重写所有的index.php,但
RewriteRule ^([^/]+)/?$ cms.php?seotitle=$1 [L]
的想法是,index.html的将加载罚款,然后在domain.com/anythinghere.html要求任何事情都会使用规则从cms.php抓取文件。
然而它不工作 - 任何线索?真的需要这种排序尽快。
试试这个规则:
RewriteCond $1 !^(cms\.php|index\.html)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/?$ cms.php?seotitle=$1 [L]
试试这个:
RewriteCond %{REQUEST_URI} !(index.html)
RewriteRule ^([^/]+)/?$ cms.php?seotitle=$1 [L]
另一种方法是使用-f
或-d
标志,这意味着现有的文件或目录。
RewriteCond %{REQUEST_URI} !-d
RewriteCond %{REQUEST_URI} !-f
RewriteRule ^([^/]+)/?$ cms.php?seotitle=$1 [L]
当您使用此,任何现有的文件或目录将不会被改写。这很有用,特别是对于css或js文件。
它不工作还。它加载我的页面模板,但不会加载内容。如果我输入浏览器mydomain.com/cms.php?seotitle=something.html,那么它工作正常,但重写仍然无法正常工作。 – seanprice 2009-10-18 16:42:55
它应该是index.php而不是.html吗?关键部分是RewriteCond。 如果仍然无法正常工作,请将rewriterule更改为类似test.php的东西,print_R($ _ GET) – davethegr8 2009-10-18 16:47:18
我按照test.php的说法进行操作,并在尝试请求mydomain.com/about时得到以下结果.html Array ([seotitle] => test.php)
–
seanprice
2009-10-18 16:58:13
繁荣 - 它的工作原理 - 非常感谢! – seanprice 2009-10-18 22:49:04