目前,我有我的网站的网址20+在此甲如何用.htaccess删除部分URl?
http://www.example.net/content/index/mission
我想从所有URL中移除/内容/索引,所以他们应该是这个样子
http://www.example.net/mission
换句话说,我会总是从url中删除/ content/index。 我确定它非常简单,但我对Apache并不是很有经验。
目前,我有我的网站的网址20+在此甲如何用.htaccess删除部分URl?
http://www.example.net/content/index/mission
我想从所有URL中移除/内容/索引,所以他们应该是这个样子
http://www.example.net/mission
换句话说,我会总是从url中删除/ content/index。 我确定它非常简单,但我对Apache并不是很有经验。
# Get rid of index.php
RewriteCond %{REQUEST_URI} /index\.php
RewriteRule (.*) index.php?rewrite=2 [L,QSA]
# Rewrite all directory-looking urls
RewriteCond %{REQUEST_URI} /$
RewriteRule (.*) index.php?rewrite=1 [L,QSA]
或者只是取决于你想要什么extention删除和mod_rewrite的是添加的index.html需要在Apache上运行。谢谢。
我也有一个脚本,我写你放在你的服务器上,然后通过浏览器浏览它,它可以确认你的服务器上是否有mod_rewrite。就我向您展示了工程100%,只要mod_rewrite的启用
我已经通过.htaccess从URL中删除index.php。所以,我想mod_rewrite已启用。但现在没有什么工作去除内容/索引 –
我会想你已经有一些重写规则到位的URL像http://www.example.net/content/index/mission
你需要找到这些规则,并添加了新的一个它采用了类似的结构,但“硬编码”的内容/索引部分,例如,假设现有一个是
RewriteRule ^content/(.*)/(.*)$ /content.php?param1=$1¶m2=$2 [L,qsa]
你想要做一个新的规则拿起/任务和重写它类似的方法,但之前现有的规则踢,例如
RewriteRule ^mission$ /content.php?param1=index¶m2=mission [L,qsa]
RewriteRule ^content/(.*)/(.*)$ /content.php?param1=$1¶m2=$2 [L,qsa]
这些只是例子 - 它将取决于您现有的规则。
可能的重复[如何从URL中删除控制器和函数名CodeIgnitor](http://stackoverflow.com/questions/7603845/how-to-remove-controller-and-function-name-from-url-在codeignitor) –