我有以下问题:我有这个网址 www.mysite.com/inde.php?SomePageName 并且我想将它重写为 www.mysite.com/SomePageName ,我想摆脱 index.php 当url 在没有任何参数的情况下被调用,例如:mysite.com/index.php 或 mysite.com/index.php?应该重定向到 mysite.com/
我的 htaccess 文件如下所示:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(index\.php)?\?([^&\ ]+)
RewriteRule ^ /%2? [L,R=302]
RewriteRule ^index.php$ http://www.mysite.com/ [R=302,L]
由于最后一个声明,现在它正在循环。
有什么办法可以做到这一点?
谢谢
PS:整个htaccess
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^cumpara-(.*)-(.*)\.html$ index.php?Profile&ID=$2 [L]
RewriteRule ^lista-scut-motor-metalic-(.*)-(.*)-(.*)\.html$ index.php?List&SubID=$3&Categorie=$1&Subcategorie=$2 [L]
RewriteRule ^scut-motor-metalic-(.*)-(.*)\.html$ index.php?ViewCat&CatID=$2 [L]
RewriteRule ^foto-(.*)-(.*).jpg$ includes/timthumb.php?src=data/$1/$2.jpg&w=300&q=100 [L]
RewriteRule ^product-(.*)-(.*).jpg$ includes/timthumb.php?src=data/$1/$2.jpg&w=530&q=100 [L]
RewriteRule ^side-(.*)-(.*).jpg$ includes/timthumb.php?src=data/$1/$2.jpg&w=175&h=110&q=100 [L]
RewriteRule ^zoom-(.*)-(.*).jpg$ data/$1/$2.jpg [L]
RewriteCond %{REQUEST_URI} ^/index.php$
RewriteCond %{QUERY_STRING} !^$
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^.*$ http://www.mysite.com/%1/? [R=302,L]
RewriteRule Despre index.php?Despre [L]
RewriteRule Help index.php?Help [L]
RewriteRule Livrare index.php?Livrare [L]
RewriteRule Contact index.php?Contact [L]
RewriteCond %{HTTP_HOST} ^mysite.com$
RewriteRule ^(.*)$ "http\:\/\/www\.mysite\.com\/$1" [R=301,L]
ErrorDocument 404 /404.html