.htaccess 需要有关mod_重写规则的帮助吗
我正在使用PHP,希望清理URL URL的形式如下:.htaccess 需要有关mod_重写规则的帮助吗,.htaccess,mod-rewrite,.htaccess,Mod Rewrite,我正在使用PHP,希望清理URL URL的形式如下: http://localhost/subfolder/index.php?controller/method/arg1 我如何将其转换为: http://localhost/subfolder/controller/method/arg1 尚未测试,但我认为您需要以下内容: RewriteRule ^/subfolder/controller/(method/.*)$ /subfolder/index.php?controller/$1
http://localhost/subfolder/index.php?controller/method/arg1
我如何将其转换为:
http://localhost/subfolder/controller/method/arg1
尚未测试,但我认为您需要以下内容:
RewriteRule ^/subfolder/controller/(method/.*)$ /subfolder/index.php?controller/$1
您可以在httpd.conf文件中尝试以下操作:
#start your engine
RewriteEngine on
#add www. for any url, not what you asked for, but kinda helpful SEO-wise
RewriteCond %{HTTP_HOST} ^mypage\.com
RewriteRule ^(.*)$ http://www.mypage.com$1
#rewrite stuff
RewriteRule ^/subfolder/(controller/method/arg1)/?$ /index.php?$1
这应该行得通。我想更改最后一行,tho:
RewriteRule ^/subfolder/(controller/method/arg1)/?$ /index.php?p=$1
现在,在重新启动apache之前,请尝试测试配置文件是否正常
user$ apachectl configtest
就这样
希望能有帮助
干杯
同一.htaccess文件中的多个重定向可以按顺序应用,这就是它的作用
RewriteRule ^products/([0-9][0-9])/$ /productinfo.php?prodID=$1 [R]
RewriteRule ^products/([0-9][0-9])$ /products/$1/