Need help with setting up the url rewrite

New to mod_rewrite? This is a good place to start.

online problem

Postby revo » Fri Oct 02, 2009 4:02 pm

I uploaded my page and htaccess online and I get a 404 page not found,
I have this in my htaccess file


Code: Select all
Options -Indexes
ErrorDocument 401 /customerrors/401.html
ErrorDocument 403 /customerrors/403.html
ErrorDocument 400 /customerrors/400.html
ErrorDocument 500 /customerrors/500.html
ErrorDocument 404 /customerrors/404.html


Options +FollowSymLinks -MultiViews

RewriteEngine On

RewriteRule ^merch/merchant/([^/]+)/?$ merch.php?merchant=$1 [QSA,L]


and my link for toys is this on my website

/merch/merchant/toys

Could it be that I'm on a shared hosting and they don't allow mod rewrite in htacces? Is there a way to check, because they kind of have not been helpful in the past when I ask.

ps I also tried this removing all those custom errors and just this

Code: Select all
Options +FollowSymLinks -MultiViews

RewriteEngine On

RewriteRule ^merch/merchant/([^/]+)/?$ merch.php?merchant=$1 [QSA,L]


and still did the same error.
revo
 
Posts: 34
Joined: Fri Feb 13, 2009 2:02 pm

Postby richardk » Sat Oct 03, 2009 8:18 am

Could it be that I'm on a shared hosting and they don't allow mod rewrite in htacces? Is there a way to check, because they kind of have not been helpful in the past when I ask.

FAQ: How to check if mod_rewrite is enabled.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby revo » Sat Oct 03, 2009 6:37 pm

Ok, that checked Ok, it redirected it to your website.
revo
 
Posts: 34
Joined: Fri Feb 13, 2009 2:02 pm

Postby richardk » Sun Oct 04, 2009 7:23 am

Check the path to merch.php. Is it at example.com/merch.php? Is the .htaccess file in your document root (example.com/.htaccess)?

To check if the rule matches, try
Code: Select all
Options +FollowSymLinks -MultiViews

RewriteEngine On

RewriteRule ^merch/merchant/([^/]+)/?$ http://www.modrewrite.com/? [R,L]

(Visiting /merch/merchant/toys/ should redirect here.)
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby revo » Mon Oct 05, 2009 6:32 am

It sent the page to your website again which shows it works. But when I put mine in, it still gives me the same error. One thing I noticed is that my host has my files in their /root/ folder so my files are all inside the /root/mywebsite.com/

or it could be my own website files are not working right so I can check them out and get back here with an update
revo
 
Posts: 34
Joined: Fri Feb 13, 2009 2:02 pm

Postby richardk » Mon Oct 05, 2009 8:22 am

It sent the page to your website again which shows it works.

Then the rule is matching, the path to merch.php must be wrong.

Do you have an error log? Look for the path in the 404 error.

Try every path to merch.php you can think of, including
Code: Select all
/merch.php
./merch.php
/root/mywebsite.com/merch.php
/mywebsite.com/merch.php
/root/merch.php


or it could be my own website files are not working right so I can check them out and get back here with an update

When you remove the ErrorDocument lines, is it an Apache 404 error or a custom 404 error?
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby revo » Mon Oct 05, 2009 9:06 am

your a genius, you did it, :D

all I had to put in my htaccess file was a / before merch.php

just now the url path adds a # at the end so for example it will say
mysite.com/merch/merchant/toys#
do you know how to stop the adding of the pound sign too?

Do I have have to put the forward slash anywhere else to get the permanent move also, or this should be fine below:

Code: Select all
Options +FollowSymLinks -MultiViews

RewriteEngine On

RewriteRule ^merch/merchant/([^/]+)/?$ /merch.php?merchant=$1 [QSA,L]
RewriteRule ^category/categoryid/([^/]+)/?$ /category.php?categoryid=$1 [QSA,L]

RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{QUERY_STRING} ^(.*&)?merchant=([^&]+)(&.*)?$ [NC]
RewriteRule ^merch\.php$ /merch/merchant/%2? [R=301,L]
RewriteRule ^category\.php$ /category/categoryid/%2? [R=301,L]
revo
 
Posts: 34
Joined: Fri Feb 13, 2009 2:02 pm

Postby richardk » Mon Oct 05, 2009 10:40 am

Code: Select all
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{QUERY_STRING} ^(.*&)?merchant=([^&]+)(&.*)?$ [NC]
RewriteRule ^merch\.php$ /merch/merchant/%2? [R=301,L]
RewriteRule ^category\.php$ /category/categoryid/%2? [R=301,L]

I already told you that that is wrong (here, post #49). No extra slashes need to be added.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby revo » Mon Oct 05, 2009 11:15 am

Sorry about that it's been a long day.
revo
 
Posts: 34
Joined: Fri Feb 13, 2009 2:02 pm

just a quick question

Postby revo » Thu Oct 15, 2009 10:24 am

Do I have to submit a new xml sitemap to google with my new urls

or

Will the modrewrite in my htaccess file be enough and google will know that I have setup new paths to the same stuff right

right now I have this in my sitemap

Code: Select all
http://www.mysite.com/merch.php?merchant=299


but my urls will be displaying this:

Code: Select all
http://www.mysite.com/store/merchant/sears
revo
 
Posts: 34
Joined: Fri Feb 13, 2009 2:02 pm

PreviousNext

Return to Beginner's Corner

Who is online

Users browsing this forum: No registered users and 13 guests

cron