2016-12-24 123 views
0

我想改變的東西像我htaccess文件無法正常工作的URL重寫

http://x.com/genre.php?type=action 
to: 
http://x.com/genre/action 

http://x.com/genre.php?type=action&arg=tv 
to 
http://x.com/genre/action?tv 

我嘗試過多種方法,但他們都沒有工作了我:

RewriteEngine On 
RewriteRule ^genre.php?type=*$ /genre/$1 [R=301,L] 

我覺得我正在談論這個完全錯誤的,有人可以照亮情況嗎?

我目前的htaccess文件只是從.php文件的末尾刪除.php文件,我成功從互聯網上的某些源文件中取出。

RewriteEngine On 

# browser requests PHP 
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^\ ]+)\.php 
RewriteRule ^/?(.*)\.php$ /$1 [L,R=301] 

# check to see if the request is for a PHP file: 
RewriteCond %{REQUEST_FILENAME}\.php -f 
RewriteRule ^/?(.*)$ /$1.php [L] 

回答

0

試試這個:

RewriteEngine on 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule ^page/(.*)/$ /genre.php?action=$1 [L] 
+0

這不是爲我工作的;( – RazeByte