[英]how to redirect with htaccess without changing the URL in browser
我有一個正常的動態網址,我希望它使SEO友好,如下所示
我的網址是
domain.com/search.php?v1=mobiles&v2=nokia
至
domain.com/search/mobiles/nokia
請幫忙
您需要使用.htaccess文件執行此重寫操作,而無需在瀏覽器中查找url,請嘗試以下代碼
RewriteEngine On #remove this if already added
RewriteRule ^search/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/?$ search.php?s1=$1&s2=$2 [NC,L]
我會這樣做:
RewriteEngine On #if not already on.
RewriteCond %{REQUEST_FILENAME} !-f #only if it is not calling a file that actually exists
RewriteCond %{REQUEST_FILENAME} !-d #only if it is not calling a directory that actually exists.
RewriteRule ([a-z0-9]+)(/*)([a-z0-9]*)(/*)([a-z0-9]*)(/*) search.php?v1=$1&v2=$3 [L,NC,QSA]
即使您僅轉至/ mobile /(假設search.php可以處理該問題),該方法也將起作用。
高溫超導
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.