开发者

How can I make the URL search engine friendly?

开发者 https://www.devze.com 2022-12-09 18:30 出处:网络
I want to cahange mysite.com/prof开发者_如何学Pythonile.php into mysite.com/profile I wrote the htacess file as

I want to cahange mysite.com/prof开发者_如何学Pythonile.php into mysite.com/profile

I wrote the htacess file as

RewriteEngine On 

RewriteRule ^profile/?$ profile.php [NC,L]

and placed in root directory. It doesn't work. I use the apache server. What is wrong with my program?


Try something like this instead:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php

That way you dont have to do it for each individual URL.

credit

0

精彩评论

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

关注公众号