1
這是我測試的.htaccess的.htaccess - 重寫規則忽略或不工作
RewriteEngine On
Options +FollowSymLinks
#WWW redirect WORKS
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule^http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteRule ^home/$ index.php [L] #THIS RULE WORKS
RewriteRule ^news/(.+)/$ /news.php?page=$1 [L] #not works
RewriteRule ^news/(.+)/$ /news.php?article=$1 [L] #not works
RewriteRule ^news/$ news.php [L] #WORKS
我想使這個:
"news.php" => "news/"
"news.php?page=3" => "news/3/"
"news.php?article=lorem-ipsum-3" => "news/lorem-ipsum-3/"
有了這個URL規則,這樣的網址效果很好,但不是我想要的:
http://www.xxxxxx.com/news/?page=3 #works
http://www.xxxxxx.com/news/?article=lorem-ipsum-2 #works
我該如何修復.htaccess?
感謝
我該如何做我想要的? 'code'「news.php」=>「news /」 「news.php?page = 3」=>「news/3 /」 「news.php?article = lorem-ipsum -3「=>」news/lorem-ipsum-3 /「'code' – benzo
將news.php與article.php分開,並分別與它們的查詢字符串一起工作,有沒有解決我的問題? – benzo
已更新的答案。 – miah