我正在尝试将我的网站URL改写为更友好的URL,例如:
www.mysite.com/profile.php
至
www.mysite.com/profile
到目前为止,我能够通过在URL地址栏中写入重写URL来完成这一任务,但是当单击链接到页面时,配置文件页URL不会更改为重写URL。我是不是漏掉了什么?
这是我的.htaccess代码
Options +FollowSymLinks
RewriteEngine On # Turn on the rewriting engine
RewriteRule ^profile/?$ profile.php [NC,L] # Handle requests for "profile"谢谢你的建议。
发布于 2013-10-25 06:32:22
您需要更改配置文件的URL。
<a href="http://www.mysite.com/profile">Profile</a>发布于 2013-10-25 06:32:01
mod_rewrite不会更改代码中的URL。你必须这么做。
如果不能或不愿意,可以使用RewriteRule和R选项将旧的URL映射到新的URL。
发布于 2013-10-25 06:43:07
它不会改变,因为您的规则只在内部将profile重写到profile.php,因此需要另一条不同的规则来实现,并且在外部将浏览器重定向:
RewriteCond %{THE_REQUEST} \ /profile\.php
RewriteRule ^ /profile [L,R]https://stackoverflow.com/questions/19582596
复制相似问题