1
我想将旧页面(如“index.php/sdasdasd/sdasda /”)重定向到它们的新内容。我使用PHP来做到这一点,因为数据存储在MySQL中。问题是,当URL以“index.php”开头时,它不会被重定向到正确的页面。在后台应该调用:“index.php?url = index.php/sdasdasd/sdasda /”。我该如何解决.htaccess中的这个问题?.htacces - 将index.php重定向到不可见的index.php
RewriteEngine on
RewriteCond %{REQUEST_URI} !(/$|\.)
RewriteRule (.*) %{REQUEST_URI}/ [R=301,L]
RewriteRule ^(.*/)?\.svn/ - [F,L]
RewriteRule \.(gif|jpg|png|css|flv|js|swf|php)$ - [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+\.php)$ index.php?url=$1 [QSA,L]
RewriteCond %{REQUEST_URI} !(\.)
RewriteCond %{REQUEST_URI} !(\.)
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} .*
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
如果您对此代码有任何其他改进,欢迎您提出更改建议。
的RewriteCond%{THE_REQUEST} \ /index\.php 重写规则^指数\ .PHP $ index.php?url = $ 1 [L,R = 301] 那么为什么不工作? index.php/test/=> url ='' – Simon
不幸的是,这是行不通的。 – Simon
@Kevin这不是我说的使用规则,不知道你从哪里得到'index.php?url = $ 1'。您希望它重定向到“/ $ 1”,例如没有'/ index.php'。或者我不明白你想要做什么? –