开发者

I can't figure out why my url rewrite isn't working

开发者 https://www.devze.com 2023-02-09 18:16 出处:网络
Hey guys. I\'m new to url rewrites but I can\'t seem to figure out why this is not working I have the link: http://thoughtsmash.com/profile.php?name=1

Hey guys. I'm new to url rewrites but I can't seem to figure out why this is not working

I have the link: http://thoughtsmash.com/profile.php?name=1

That I want to rewrite to: http://thoughtsmash.com/profilename/1

and I have this in my .htaccess file:

Options +FollowSymlinks
RewriteEngine on
RewriteCond %{H开发者_JAVA技巧TTP_HOST} ^www\.(.*) [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,NC,L]
RewriteRule ^/profilename/([0-9_]+)$ /profile.php?name=$1 [NC]

But it does nothing! The removal of the "www." works fine but the rest doesn't. Any ideas as to why? Thanks


Try this:

Options +FollowSymlinks
RewriteEngine on

RewriteBase /

RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,NC,L]

RewriteRule ^profilename/([0-9_]+)$ /profile.php?name=$1 [NC]

Note that I added RewriteBase and removed leading /

0

精彩评论

暂无评论...
验证码 换一张
取 消