Page 1 of 1
Problem in loading page after url rewriting.
Posted: Mon Jan 12, 2009 6:53 am
by kalpesh
hi, i try to workout url rewriting in my site.
It works fine.
But It seems to be when i go to front page at that time it is not loading.
I give you full scenario.
The main page without cookie working first time fine.
At .htaccess code is as follows.
Code: Select all
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/?([^/]+)(/index.html)? City/index.php?City=$1 [QSA]
.htaccess file is in root.
when i change city from dropdown box.At that time cookie stored and page loads which url like this:
http://www.example.com/New York/index.html
If cookie is there then every time user request for home page that time above city page will be displayed.
But Now Problem starts , when I delete cookie and try to load root index page
at that time page is not loading and url changed to something like this:
http://www.example.com/Script/index.html
or sometimes
http://www.examples.com/style/index.html
I don't know what going wrong.
Please help me .
Thanks in advance.
Re: Problem in loading page after url rewriting.
Posted: Mon Jan 12, 2009 6:52 pm
by clungtech
thanks for posting this type of result. i am enjoying to read this.
Re: Problem in loading page after url rewriting.
Posted: Mon Jan 12, 2009 6:56 pm
by Benjamin
clungtech wrote:thanks for posting this type of result. i am enjoying to read this.
SPAMMER!
Re: Problem in loading page after url rewriting.
Posted: Mon Jan 12, 2009 9:02 pm
by requinix
astions wrote:SPAMMER!
And your reply helped the OP... how?
The RewriteRules I gave you, kalpesh, say nothing about a Script or style directory. Something else is to blame.
All I can do now is blindly guess what the problem is but that won't help anybody.
Re: Problem in loading page after url rewriting.
Posted: Mon Jan 12, 2009 11:34 pm
by kalpesh
The problem is solved.
The problem is because two .htaccess in two folders.
When i remove all .htaccess in all folders and only save root folder .htaccess
then it works perfectly well.
I want to ask u tasaris about problem in creating url rewriting rule.
This time i want to create to rule for url like this:
http://www.example.com/City/Product/Pro ... ty=NewYork
And I want url like this:
http://www.example.com/NewYork/ProductN ... duct1.html
What i try to do
Code: Select all
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/?([^/]+)^([a-zA-Z0-9_-]+)/Product([^.]).html$ City/Product/Product.php?Id=$2&City=$1 [QSA]
I store .htaccess in Root folder
I also create Another .htaccess file and store in City folder where code is:
Code: Select all
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-zA-Z0-9_-]+)/Product([^.]).html$ Product/Product.php?Id=$1&City=$2 [QSA]
When i type url as above.
It shows page but contents shown by page is city index page.
Please help me.
Thanks in advance.
Re: Problem in loading page after url rewriting.
Posted: Tue Jan 13, 2009 12:05 am
by requinix
I don't remember which thread I said it in (or even if it was this forum) but the .htaccess file should go in the directory where the URL
won't change. Don't put it in City/ because you don't want the rewrite rule to be in the City/ directory (you want it in NewYork/).
I'll say this again: you should be asking in the Regex forum. RewriteRules don't really have anything to do with PHP so this isn't the best place to ask.
Code: Select all
# Change
#/NewYork/ProductName/Product1.html to
#/City/Product/Product.php?Id=1&City=NewYork
# $1=NewYork $2=ProductName $3=Product $4=1
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/?([^/]+)/([^/]+)/([^.]*\D)(\d+)(\.html)?$ /City/Product/Product.php?Id=$4&City=$1 [L,QSA]
As I said, this should be in the root .htaccess.
Now please, if you need to ask more RewriteRule questions, (a) ask in the Regex forum, and (b) spell out exactly what parts of the URL go where. I said last time I didn't know where "Product" was supposed to go: nobody else does either so you need to tell us.