我如何更改htaccess呢

时间:2017-04-07 19:17:18

标签: .htaccess

目前的做法是将网址从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]

但这没有做任何事情:(

1 个答案:

答案 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]