[英]Mod_rewrite - url rewriting isn't working
我一直試圖讓我的.htaccess文件中的mod_rewrite在過去幾個小時內工作,但我似乎無法將它拉下來。 .htaccess文件肯定可以在我的服務器上運行,因為我之前使用過它們。
我試圖用這個生成器重寫它並使用這個工具以及我的服務器進行測試。
網址
我需要轉
http://someurl.com/news-detail.html?id=10&news=this-is-an-article
成
http://someurl.com/news/10/this-is-an-article
要么
http://someurl.com/10/news/this-is-an-article
改寫
我試過了:
RewriteEngine On
RewriteRule ^([^/]*)/news/([^/]*)$ /news-detail.html?id=$1&news=$2 [L]
和
RewriteEngine on
RewriteRule /(.*)/news/(.*) news-detail.html?id=$1&news=$2 [L]
和
RewriteEngine on
RewriteRule news/([0-9]+)/([a-zA-Z_]+)$ news-detail.html?id=$1&news=$2 [L]
和許多其他人。
我希望有人能在這里幫助我..
請在.htaccess文件中檢查/添加RewriteBase。 還要檢查是否允許htaccess重寫。 語法如下
RewriteEngine on
RewriteBase /flodername/
RewriteRule ^urlinbrowser/(.*)/(.*)$ filename.php?first_param=$1&secondparam=$2 [L]
在root .htaccess中保留這樣的規則:
RewriteEngine On
RewriteBase /dev/hoig/
RewriteCond %{THE_REQUEST} /news-detail\.html\?id=([^\s&]+)&news=([^\s&]+) [NC]
RewriteRule ^ %1/news/%2? [R=302,L]
RewriteRule ^([^/]+)/news/([^/]+)/?$ news-detail.html?id=$1&news=$2 [L,NC,QSA]
這將支持/10/news/this-is-an-article
URI結構,用於漂亮的URL。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.