我的目的是在地址栏输入的url:
http://localhost/project/ShortURL/index.php/149Ui3
自动重写为
http://localhost/project/ShortURL/index.php?controller=jump&method=jemp&code=149Ui3
apache中添加配置如下(apache2.conf):
1.在/var/www/project/ShortURL目录下建立一个.htaccss文件内容如下:
# Turn on rewrite engine
Options +FollowSymlinks
RewriteEngine on
# More rules below
RewriteRule ^index.php/(.*)$ index.php?controller=jump&method=jump&code=$1 [QSA]
2.在apach2.conf中做了如下配置:
<Directory /var/www/project/ShortURL>
Options FollowSymLinks
AllowOverride ALL
Require all granted
</Directory>
现在问题是每次输入http://localhost/project/ShortURL/index.php/149Ui3都会显示没有css样式控制的http://localhost/project/ShortURL/index.php内容(地址栏还是http://localhost/project/ShortURL/index.php/149Ui3),不能跳转到http://localhost/project/ShortURL/index.php?controller=jump&method=jemp&code=149Ui3这个地址
问题已解决,总结一下
问题描述
我的目的是在地址栏输入的url:
http://localhost/project/ShortURL/index.php/149Ui3
自动重写为
http://localhost/project/ShortURL/index.php?controller=jump&method=jump&code=149Ui3
解决方案
1.在apach2.conf中做如下配置:
<Directory /var/www/project/ShortURL>
Options FollowSymLinks
AllowOverride ALL
Require all granted
</Directory>
2.在/var/www/project/ShortURL目录下建立一个.htaccss文件内容如下:
# Turn on rewrite engine
RewriteEngine on
# More rules below
RewriteBase /
RewriteRule ^index.php/(.*)$ http://localhost/project/ShortURL/index.php?controller=jump&method=jump&code=$1 [L,R=301]
写在最后
感谢开源中国疯狂的蜗牛提供的思路.一点启发,没事多看文档吧,还有一点,浏览器缓存太坑爹了,要不是它早就没这么麻烦了.