Snippet
Snippet

Reputation: 1560

RewriteRule Cause Slow Down

I have added a RewriteRule in my site

my site has its own routing.

Sample

http://site.com/home/task/processCity/cityName/NameOfCity/stateName/NameOfState

equivalent to

http://site.com/index.php?obj=home&task=processCity&cityName=NameOfCity&landingName=NameOfState

I tried to shortent the url to

http://site.com/NameOfCity/NameOfState

with the following code below

as i have notice. this code makes the site load slow. or css and javascript are not working.

RewriteRule ^(.*)/(.*)? /index.php?obj=home&task=processCity&cityName=$1&stateName=$2 [QSA,NC,L]

and the original link is not working

http://site.com/home/task/processCity/cityName/NameOfCity/stateName/NameOfState

but when i use this one everything works fine also the original link is still working

RewriteRule ^find/(.*)/(.*)? /index.php?obj=home&task=processCity&cityName=$1&stateName=$2 [QSA,NC,L]

what could be the cause of the problem in the first RewriteRule? any way to fix this ?

Upvotes: 2

Views: 342

Answers (1)

anubhava
anubhava

Reputation: 784918

Original link isn't working because your regex is not correct, without $ it is matching and impacting your long URL as well. Change your rule to:

RewriteRule ^([^/]+)/([^/]*)/?$ /index.php?obj=home&task=processCity&cityName=$1&stateName=$2 [QSA,L]

Upvotes: 4

Related Questions