要做到这一点:删除扩展,并添加与traling GET值削减
原始地址 - >localhost/viewprofile.php
重写URL - >localhost/viewprofile/
我用这个代码。
# Apache Rewrite Rules
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteBase/
# 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
# End of Apache Rewrite Rules
</IfModule>
我们做到这一点我用
原始地址 - >localhost/viewprofile.php?user_id = 1
重写URL - >localhost/1/
RewriteEngine On
RewriteRule ^([a-zA-Z0-9_-]+)$ viewprofile.php?user_id=$1
RewriteRule ^([a-zA-Z0-9_-]+)/$ viewprofile.php?user_id=$1
但不幸的是我想这样做
原始地址 - >localhost/viewprofile.php?user_id = 1
重写URL - >localhost/viewprofile/1/
这
原始地址 - >localhost/viewprofile.php?username=sean
重写URL - >localhost/viewprofile/sean/
我有这两个Original URLs
,我想上面给出分别重写他们作为各自ReWrite URL
。
任何任何解决方案?
请简单介绍一下你的问题,以便其他人可以理解,并相应地回答。 – PSN
'原始URL'就是我所拥有的'ReWrite URL'就是我想要实现的。 @PSN –