简体   繁体   中英

Pretty URL’s and mod_rewrite

I can't seem to make this work - and I'm pretty sure that the real problem is that I just starring myself blind on it, so I hope a pair of fresh eyes can help me out.

What I wan't to do is have several applications attached to my system. At this time, a website already exists in the root folder, but I wan't some microsites/powerformats in a CI installation.

My mod_rewrite looks like this:

RewriteCond %{REQUEST_URI} ^/(powerformat1|powerformat2)/?$
RewriteRule ^(.*)$ powerformats/index.php/$1 [L] 

Although, getting the CI index.php correctly, when trying to access example.org/powerformat1 or example.org/powerformat2 gives me CI's 404 page.

It seems like whatever I try of rewrite rules I either get the 404 page or nothing at all.

Any insights?

-- EDIT --

What I believe is my problem is that CI actually gets the 'powerformat1' string passed as the first segment. That is what I need to avoid. But can't that be solved through mod_rewrite?

你错过了RewriteEngine On吗?

You could try link directly to the file with the appropriate query string instead

RewriteRule ^(.*)$ /powerformats/index.php?somequery=$1 [L]
(you may have to change the slashes, see below)

Or it may be this:

Accessing /powerformat1/ may be rewriting to
powerformats/index.php//powerformat1/

You could try
RewriteRule ^/(.*)/$ /powerformats/index.php/$1 [L]
or some other variation with slashes:
RewriteRule ^/(.*)/$ /powerformats/index.php/$1/ [L]

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