我在我的网站上有一些网址,如下所示。
http://www.mydomain.com/about.php
http://www.mydomain.com/contact.php
http://www.mydomain.com/signup.php
http://www.mydomain.com/testimonials.php ...... and much more 现在我正在尝试转换上述网址为用户友好的网址
http://www.mydomain.com/about
http://www.mydomain.com/contact
http://www.mydomain.com/signup
http://www.mydomain.com/testimonials这是我到目前为止尝试过的.htaccess文件中的代码。但它不起作用。
# Add trailing slash to url
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/|#(.*))$
RewriteRule ^(.*)$ $1/ [R=301,L]
# Remove .php-extension from url
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^([^\.]+)/$ $1.php 任何人可以帮助我删除我的urls中的.php尺寸??谢谢。
发布于 2013-05-19 17:07:21
去掉正在使用的条件,改用htaccess文件中的以下2行代码
RewriteEngine On # Turn on the rewriting engine
RewriteRule ^whatever/?$ whatever.php [NC]即使用户在名称后键入正斜杠或不键入正斜杠,这也会起作用
如果你想让它们动态化,是一个很好的教程
发布于 2013-05-19 19:32:18
如果您没有访问服务器的htaccess文件的权限,或者如果它被覆盖,就不会在部署过程中造成混乱。您可以考虑使用像toro-php http://toroweb.org/这样的库来简化路由。
https://stackoverflow.com/questions/16633006
复制相似问题