Php 如何使用htaccess重定向而不更改浏览器中的URL
我有一个正常的动态网址,我希望它使搜索引擎优化友好如下 我的网址是Php 如何使用htaccess重定向而不更改浏览器中的URL,php,apache,.htaccess,xampp,Php,Apache,.htaccess,Xampp,我有一个正常的动态网址,我希望它使搜索引擎优化友好如下 我的网址是 domain.com/search.php?v1=mobiles&v2=nokia 到 请帮助您需要使用.htaccess文件执行此重写操作,而无需在浏览器中设置url, 请尝试下面的代码 RewriteEngine On #remove this if already added RewriteRule ^search/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/?$ search.php
domain.com/search.php?v1=mobiles&v2=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]
您需要使用.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可以处理这个问题),这也会起作用
HTH我会这样做:
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可以处理这个问题),这也会起作用
嗯