我的htaccess文件不适用于URL重写

时间:2016-12-24 00:43:44

标签: .htaccess

我想改变像

这样的东西
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]

1 个答案:

答案 0 :(得分:0)

试试这个:

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