[英]htaccess Dynamic Redirect that changes URL in clients browser
I am trying to redirect /search.php?s=xxx
to /search/xxx
and actually show /search/xxx in client's address bar.我正在尝试将/search.php?s=xxx
重定向到/search/xxx
并在客户端的地址栏中实际显示 /search/xxx 。
I am using the following instruction in the htaccess root and it works but doesn't change the URL :我在 htaccess 根目录中使用以下指令,它可以工作,但不会更改 URL :
RewriteRule ^search/(.*)$ /search.php?s=$1
I have tried adding [R=301] at the end of the statement, so:我尝试在语句末尾添加 [R=301] ,所以:
RewriteRule ^search/(.*)$ /search.php?s=$1 [R=301]
But this does the opposite, meaning it changes /search/xxx to /search.php?s=xxx但这恰恰相反,这意味着它将 /search/xxx 更改为 /search.php?s=xxx
Here is the entire .htaccess file:这是整个 .htaccess 文件:
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^monumentum$ /new_monumentum.php
RewriteRule ^monumentum/(.*)$ /new_monumentum.php?mid=$1
RewriteRule ^nuntium$ /new_articulo.php
RewriteRule ^nuntium/(.*)$ /new_articulo.php?aid=$1
RewriteRule ^liber$ /new_liber.php
RewriteRule ^liber/(.*)$ /new_liber.php?lid=$1
RewriteRule ^introductio$ /new_pagina.php
RewriteRule ^introductio/(.*)$ /new_pagina.php?pid=$1
RewriteRule ^persona$ /new_profile.php
RewriteRule ^persona/(.*)$ /new_profile.php?cid=$1
#RewriteRule ^search$ /new_search.php
#RewriteRule ^search/(.*)$ /new_search.php?sea=$1
RewriteRule ^exitio$ /new_exit.php
RewriteRule ^intro$ /new_enter.php
RewriteRule ^novus$ /new_account.php
# Error 404: Paginas no encontradas
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
ErrorDocument 403 /403.html
ErrorDocument 404 /404.html
To redirect /search.php?s=xxx
to /search/xxx
, you may use this rule:要将/search.php?s=xxx
重定向到/search/xxx
,您可以使用以下规则:
Options -MultiViews
RewriteEngine On
RewriteCond %{THE_REQUEST} /search\.php\?s=([^\s&]+) [NC]
RewriteRule ^ /search/%1? [R=301,L,NE]
RewriteRule ^search/(.+)$ search.php?s=$1 [L,NC,QSA]
# place your remaining rules below here
RewriteRule ^monumentum$ new_monumentum.php [L]
RewriteRule ^monumentum/(.*)$ new_monumentum.php?mid=$1 [L,QSA]
RewriteRule ^nuntium$ new_articulo.php [L]
RewriteRule ^nuntium/(.*)$ new_articulo.php?aid=$1 [L,QSA]
RewriteRule ^liber$ new_liber.php [L]
RewriteRule ^liber/(.*)$ new_liber.php?lid=$1 [L,QSA]
RewriteRule ^introductio$ new_pagina.php [L]
RewriteRule ^introductio/(.*)$ new_pagina.php?pid=$1 [L,QSA]
RewriteRule ^persona$ new_profile.php [L]
RewriteRule ^persona/(.*)$ new_profile.php?cid=$1 [L,QSA]
RewriteRule ^exitio$ new_exit.php [L]
RewriteRule ^intro$ new_enter.php [L]
RewriteRule ^novus$ new_account.php [L]
# Error 404: Paginas no encontradas
ErrorDocument 403 /403.html
ErrorDocument 404 /404.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.