Page 1 of 1
small reguller express issue
Posted: Tue Mar 11, 2008 9:22 am
by itsmani1
Here is my express:
Code: Select all
RewriteEngine on
RewriteRule ^shop/(.*)/ index.php [nc]
what's is happening is its converting every .com/shop/anything/ to index.php
its transferring correctly you can check it at
http://beta.cmela.com/shop/dizyn/
But there is problem of images and css, they are not working, what can i do for this?
thank you
Re: small reguller express issue
Posted: Tue Mar 11, 2008 11:31 am
by Zoxive
itsmani1 wrote:Here is my express:
Code: Select all
RewriteEngine on
RewriteRule ^shop/(.*)/ index.php [nc]
what's is happening is its converting every .com/shop/anything/ to index.php
its transferring correctly you can check it at
http://beta.cmela.com/shop/dizyn/
But there is problem of images and css, they are not working, what can i do for this?
thank you
That Regular Expression is working exactly how it was written.
Making the Rewrite route everything to index.php, .* matches everything.
A common way to combat this is with a check to see if the file or folder actually exist, then stop rewriting.
Code: Select all
RewriteCond %{SCRIPT_FILENAME} -f [OR] # If it is a File
RewriteCond %{SCRIPT_FILENAME} -d # Or it is a Directory
RewriteRule .* - [L] # Route to that, Last Rule
Re: small reguller express issue
Posted: Wed Mar 12, 2008 12:39 am
by GeertDD
Or even:
Code: Select all
...
RewriteRule ^ - [L] # Route to that, Last Rule
You can stop matching right at the beginning.
Re: small reguller express issue
Posted: Fri Apr 25, 2008 3:49 am
by itsmani1
I tired following code but no luck
Please see:
http://beta.cmela.com/shop/dizyn/
Code: Select all
RewriteEngine on
RewriteRule ^shop/(.*) index.php [NC]
rewritecond %{script_filename} -f
rewritecond %{script_filename} -ds