规则重写不起作用 - 很好的网址

时间:2015-12-09 15:22:17

标签: .htaccess mod-rewrite

我尝试了很多。切换了很多标志,仍然无效。

我需要

http://www.wealthuniversity.eu/unsubscribe?id=87545783KQHWLUEGI79W

看起来像

http://www.wealthuniversity.eu/unsubscribe/87545783KQHWLUEGI79W

该怎么办?

我的代码是

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f

RewriteCond %{HTTP_HOST} ^(wealthuniversity\.eu)(:80)? 
RewriteRule (.*) http://www.wealthuniversity.eu/$1 [R=301]

RewriteRule ^([^\.]+)$ $1.php
RewriteRule ^/$ /index.php [R=301]

RewriteRule   ^unsubscribe/([A-Za-z0-9-]+)$   ^unsubscribe?id=$1

#and other things

是否有任何标志或什么?

谢谢!

1 个答案:

答案 0 :(得分:1)

试试这个htaccess:

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^wealthuniversity.eu$ 
RewriteRule ^(.*)$ http://www.wealthuniversity.eu/$1 [R,L]
RewriteRule ^/?$ /index.php [R,L]

RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME}.php -f
RewriteRule ^/?([^\.]+)/?$ /$1.php [NC,L]

RewriteRule   ^/?unsubscribe/([A-Za-z0-9-]+)/?$ /unsubscribe?id=$1 [NC,L]