我的目的是在地址栏输入的url:
http://localhost/project/ShortURL/index.php/149Ui3
自动重写为
http://localhost/project/ShortURL/index.php?controller=jump&method=jemp&code=149Ui3
apache中添加配置如下(apache2.conf):
<IfModule mod_rewrite.c> # Turn on rewrite engine Options +FollowSymlinks RewriteEngine on # More rules below RewriteRule ^index.php/(.*)$ index.php?controller=jump&method=jump&code=$1 [QSA]</IfModule>
1.httpd.conf中rewrite模块是否正确开启
2.你写入的这个配置文件是否有效
我在ubuntu下,没有发现httpd.conf文件,主配置文件只有apach2.conf,另外现在的配置是这样的.
1.在/var/www/project/ShortURL目录下建立一个.htaccss文件内容如下:
# Turn on rewrite engineOptions +FollowSymlinksRewriteEngine on# More rules belowRewriteRule ^index.php/(.*)$ index.php?controller=jump&method=jump&code=$1 [QSA
<Directory /var/www/project/ShortURL> Options FollowSymLinks AllowOverride ALL Require all granted</Directory>
1.httpd.conf中rewrite模块是否正确开启
2.你写入的这个配置文件是否有效
问题解决了,总结一下:
问题描述:
我的目的是在地址栏输入的url:
http://localhost/project/ShortURL/index.php/149Ui3
自动重写为
http://localhost/project/ShortURL/index.php?controller=jump&method=jump&code=149Ui3
a4b561c25d9afb9ac8dc4d70affff419解决方案0d36329ec37a2cc24d42c7229b69747a
1.在apach2.conf中做如下配置:
a9fdb1c0abf02feb53ec38fbe21d58ae
Options FollowSymLinks
AllowOverride ALL
Require all granted
bb15ed4aadeed04b3991578461de0768
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=j ump&code=$1 [L,R=301]
a4b561c25d9afb9ac8dc4d70affff419写在最后0d36329ec37a2cc24d42c7229b69747a
没事的时候还得多看文档啊,感谢开源中国疯狂的蜗牛提供的思路.