簡體   English   中英

.htaccess重定向問題

[英].htaccess redirect issue

我陷入了這個.htaccess問題,無法得到解決方案。 嘗試了一切,但因為我是htaccess的新手可能是代碼不匹配,它給了我一個錯誤。

有一個我正在工作的php文件..

這是我現在得到的結果

http://website.com/page.php?url=diploma-in-film-acting

現在我想讓它像這樣工作

http://website.com/diploma-in-film-acting

或者可能是這個

http://website.com/diploma-in-film-acting.html

我如何讓它工作?

我已經使用過這段代碼了

我已經這樣做但是當我將其添加到網址時出現404錯誤http://website.com/diploma-in-film-acting.html

RewriteEngine On

RewriteRule ^([a-zA-Z0-9-/]+).html$ page.php?url=$1
RewriteRule ^([a-zA-Z0-9-/]+).html/$ page.php?url=$1

謝謝

RewriteEngine On
RewriteRule ^([^/]*)\.html$ /page.php?url=$1 [L]

使用Apache的mod_rewrite 在你的.htaccess ,給這個:

RewriteEngine On
RewriteRule ^([^/]*)\.html$ /page.php?url=$1&%{QUERY_STRING} [L]

對於基於目錄的重寫,請使用:

RewriteEngine On
RewriteRule ^([^/]*)\.html$ /page.php?url=$1&%{QUERY_STRING} [L]
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*)$ /page.phpurl$1&%{QUERY_STRING}

(可選)如果您有任何查詢字符串,將通過&%{QUERY_STRING}

它現在有效: -

RewriteEngine On

RewriteRule ^([a-zA-Z0-9-/]+).html$ page.php?url=$1
RewriteRule ^([a-zA-Z0-9-/]+).html/$ page.php?url=$1

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM