How can I make the URL search engine friendly?

不羁岁月 提交于 2019-12-25 06:21:27

问题


I want to cahange mysite.com/profile.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?


回答1:


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



来源:https://stackoverflow.com/questions/1653520/how-can-i-make-the-url-search-engine-friendly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!