htaccess url 重写,删除查询字符串和文件扩展名
我当前的网址类似于:
http://something.somedomain.com/about_us/ profile.php?tab1=about_us
我想让它们更短:
http://something.somedomain.com/about_us/profile http://something.somedomain.com/exchange_hosting/feature/outlook_web_access
我的.htaccess
#################################
# Directory Indexes #
#################################
DirectoryIndex index.php
#########################################
# REWRITE RULES #
#########################################
RewriteEngine On
RewriteBase /
Options +FollowSymlinks
<IfModule mod_rewrite.c>
#not a file
RewriteCond %{REQUEST_FILENAME} !-f
#not a dir
RewriteCond %{REQUEST_FILENAME} !-d
#this dosen't work
#RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)$ /$1.php?tab1=$0&tab2=$1
</IfModule>
# END #
my current url is something like:
http://something.somedomain.com/about_us/profile.php?tab1=about_us
a more complicated on is:
http://something.somedomain.com/exchange_hosting/feature/outlook_web_access.php?tab1=exchange_hosting&tab2=feature&tab3=outlook_web_access
i want to make them shorter:
http://something.somedomain.com/about_us/profile
http://something.somedomain.com/exchange_hosting/feature/outlook_web_access
my .htaccess
#################################
# Directory Indexes #
#################################
DirectoryIndex index.php
#########################################
# REWRITE RULES #
#########################################
RewriteEngine On
RewriteBase /
Options +FollowSymlinks
<IfModule mod_rewrite.c>
#not a file
RewriteCond %{REQUEST_FILENAME} !-f
#not a dir
RewriteCond %{REQUEST_FILENAME} !-d
#this dosen't work
#RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)$ /$1.php?tab1=$0&tab2=$1
</IfModule>
# END #
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试以下两种尺寸。对于更长的 url,您必须编写更多此类规则。
Try following for two sizes. For more lengthier url you have to write more such rules.