htaccess url重写,删除查询字符串和文件扩展名 [英] htaccess url rewrite,remove querystring and file extension
本文介绍了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
http://something.somedomain.com/about_us/profile http://something.somedomain.com/exchange_hosting/feature/outlook_web_access
我的.htaccess
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 #
推荐答案
尝试以下两种尺寸。要获取更长的网址,您必须编写更多此类规则。
Try following for two sizes. For more lengthier url you have to write more such rules.
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/?$ $1/$2.php?tab1=$1&tab2=$2 [L]
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/?$ $1/$2/$3.php?tab1=$1&tab2=$2&tab3=$3 [L]
这篇关于htaccess url重写,删除查询字符串和文件扩展名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文