目前的做法是将网址从http://example.com/index.php?link=djasfjk更改为http://example.com/djasfjk
但它显示索引页面。如何制作它以显示url.php而不是index.php
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+(?:index\.php|)\?link=([^\s]+) [NC]
RewriteRule ^ /%1? [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.+?)/?$ /?link=$1 [L,QSA]
我试过改变:
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+(?:index\.php|)\?link=([^\s]+) [NC]
RewriteRule ^ /%1? [R=301,L]
到
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+(?:url\.php|)\?link=([^\s]+) [NC]
RewriteRule ^ /%1? [R=301,L]
但这没有做任何事情:(
答案 0 :(得分:0)
您可以使用此.htaccess:
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+(?:(?:url|index)\.php)?\?link=([^&\s]+) [NC]
RewriteRule ^ /%1? [R=301,L,NE]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.+?)/?$ url.php?link=$1 [L,QSA]