0
我很新手在修改与.htaccess和我需要一些帮助,使其工作。使用.htaccess自动URL重写
例如,我有这两个网址:
- www.example.com/categories/example1
- www.example.com/categories/example2
,我想自动把它改写为:
- www.example.com/mypage/?cat=example1
- www.example.com/mypage/?cat=example2
有没有办法用.htaccess重写?
我已经尝试过这一点,但仍然没有工作...
RewriteEngine On
RewriteBase/
RewriteRule ^example1([^/]*)$ mypage/?cat=$1 [L]
RewriteCond %{THE_REQUEST} ^(GET|POST|HEAD|TRACE)\ /mypage/
RewriteCond %{QUERY_STRING} name=([^\&]*)
RewriteRule ^mypage/$ categories/%1.php? [R,L]
它不工作。这是因为我使用wordpress,我必须在代码中添加其他内容? –
@JohnSmith如果你使用wordpress,那么使用WordPress的内置重写永久链接 –
但我不能使用.htaccess做到这一点? –