[英]How to change Our website URL using htaccess
我是PHP新手,因此在使用.htacess
進行URL重定向時遇到了一些問題。
我的URL頁面如下所示: http://domain.com/blog_detail.php?id=blog_title
: http://domain.com/blog_detail.php?id=blog_title
但是我想使用.htaceess
這樣更改URL: http://domain.com/blog/blog_title
: .htaceess
我已經嘗試過了,但是沒有用:
<IfModule mod_rewrite.c>
RewriteEngine on # Turn on the rewriting engine
RewriteRule ^blog/([a-zA-Z0-9_-]+)$ blog_detail.php?id=$1
</IfModule>
我會用:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f ## respect real files
RewriteCond %{REQUEST_FILENAME} !-d ## respect real directories
RewriteBase /
RewriteRule ^blog/(.*)$ blog_detail.php?id=$1&%{QUERY_STRING} [L]
&%{QUERY_STRING},僅當您想要在此處傳遞其他變量時,例如:
http://domain.com/blog/blog_title?lang=fr
例如
嘗試這個:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteRule ^(.*)$ blog_detail.php?id=$1 [QSA,L]
</IfModule>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.