Any questions involving matching text strings to patterns - the pattern is called a "regular expression."
Moderator: General Moderators
itsmani1
Forum Regular
Posts: 791 Joined: Mon Sep 29, 2003 2:26 am
Location: Islamabad Pakistan
Contact:
Post
by itsmani1 » Tue Mar 11, 2008 9:22 am
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
Zoxive
Forum Regular
Posts: 974 Joined: Fri Apr 01, 2005 4:37 pm
Location: Bay City, Michigan
Post
by Zoxive » Tue Mar 11, 2008 11:31 am
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
GeertDD
Forum Contributor
Posts: 274 Joined: Sun Oct 22, 2006 1:47 am
Location: Belgium
Post
by GeertDD » Wed Mar 12, 2008 12:39 am
Or even:
Code: Select all
...
RewriteRule ^ - [L] # Route to that, Last Rule
You can stop matching right at the beginning.
itsmani1
Forum Regular
Posts: 791 Joined: Mon Sep 29, 2003 2:26 am
Location: Islamabad Pakistan
Contact:
Post
by itsmani1 » Fri Apr 25, 2008 3:49 am
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