简体   繁体   中英

mod_rewrite hid part of url

Hey guys, I did a bunch of google searching but I couldn't figure out how to get mod_rewrite working for my purpose.

Here is my url:

http://localhost/symfony2/web/index.php

I would like to hide the web/index.php section so that this:

http://localhost/symfony2/web/index.php/hello/bob

turns to this:

http://localhost/symfony2/hello/bob

Nothing seems to be working right now. It just keeps showing my folder structure. Here's what I currently have:

RewriteCond %{REQUEST_URI} !web/
RewriteRule (.*) localhost/symfony2/web/index.php$1 [L]

(Also posted at http://forum.symfony-project.org/viewtopic.php?f=23&t=31361 .)

RewriteBase /symfony2
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ web/index.php/$1 [L,QSA]

(The !-f and !-d are to make sure that if there is a file or directory match it won't rewrite it.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM