Forum Moderators: phranque

Message Too Old, No Replies

.htaccess and 301 redirect issue

Using a CMS with mod-rewrite, my redirects dont work...

         

seosutra

7:11 am on Apr 27, 2007 (gmt 0)

10+ Year Member



Hello All,

I am using a TikiWiki CMS, recently I was trying to set up 301 for my OLD pages to new ones...

However, It doesnt seem to work and this is mostly due to the Mod Rewrite set up for my CMS,

I am trying to find a way to get around it...
this is what i am using to get the redirects:

RedirectMatch permanent ^/Old+Page+Name$ [mysite.com...]

Below is the code from my .htaccess file:
-----------------------------------------

RewriteEngine On

# Inspired by Loyd Wood
# [tikiwiki.org...]

# direct one-word access
RewriteRule ^articles/$ /tiki-view_articles.php [L]
RewriteRule ^blogs/$ /tiki-list_blogs.php [L]
RewriteRule ^categories/$ /tiki-browse_categories.php [L]
RewriteRule ^charts/$ /tiki-list_charts.php [L]
RewriteRule ^chat/$ /tiki-chat.php [L]
RewriteRule ^contact/$ /tiki-contact.php [L]
RewriteRule ^directories/$ /tiki-directory_browse.php [L]
RewriteRule ^eph/$ /tiki-eph.php [L]
RewriteRule ^faqs/$ /tiki-list_faqs.php [L]
RewriteRule ^files/$ /tiki-file_galleries.php [L]
RewriteRule ^forums/$ /tiki-forums.php [L]
RewriteRule ^images/$ /tiki-galleries.php [L]
RewriteRule ^galleries/$ /tiki-galleries.php [L]
RewriteRule ^games/$ /tiki-list_games.php [L]
RewriteRule ^my/$ /tiki-my_tiki.php [L]
RewriteRule ^newsletters/$ /tiki-newsletters.php [L]
RewriteRule ^quizzes/$ /tiki-list_quizzes.php [L]
RewriteRule ^stats/$ /tiki-stats.php [L]
RewriteRule ^surveys/$ /tiki-list_surveys.php [L]
RewriteRule ^trackers/$ /tiki-list_trackers.php [L]
RewriteRule ^irc/$ /tiki-irc_logs.php [L]
RewriteRule ^mobile/$ /tiki-mobile.php [L]
RewriteRule ^wml/$ /tiki-mobile.php [L]
RewriteRule ^wiki/$ /tiki-index.php [L]

# access any object by its numeric identifier
RewriteRule ^article/([0-9]+)$ /tiki-read_article.php?articleId=$1 [QSA,L]
RewriteRule ^art([0-9]+) /tiki-read_article.php?articleId=$1 [QSA,L]
RewriteRule ^category/([0-9]+) /tiki-browse_categories.php?parentId=$1 [QSA,L]
RewriteRule ^blog/([0-9]+) /tiki-view_blog.php?blogId=$1 [QSA,L]
RewriteRule ^chart/([0-9]+) /tiki-view_chart.php?chartId=$1 [QSA,L]
RewriteRule ^faq/([0-9]+) /tiki-view_faq.php?faqId=$1 [QSA,L]
RewriteRule ^file/([0-9]+) /tiki-list_file_gallery.php?galleryId=$1 [QSA,L]
RewriteRule ^download/([0-9]+) /tiki-download_file.php?fileId=$1 [QSA,L]
RewriteRule ^forum/([0-9]+) /tiki-view_forum.php?forumId=$1 [QSA,L]
RewriteRule ^gallery/([0-9]+) /tiki-browse_gallery.php?galleryId=$1 [QSA,L]
RewriteRule ^newsletter/([0-9]+) /tiki-newsletters.php?nlId=$1 [QSA,L]
RewriteRule ^quiz/([0-9]+) /tiki-take_quiz.php?quizId=$1 [QSA,L]
RewriteRule ^survey/([0-9]+) /tiki-take_survey.php?surveyId=$1 [QSA,L]
RewriteRule ^tracker/([0-9]+) /tiki-view_tracker.php?trackerId=$1 [QSA,L]
RewriteRule ^wiki/([A-Za-z0-9]+) /tiki-index.php?page=$1 [QSA,L]
RewriteRule ^irc([0-9]+) /tiki-irc_logs.php?focus=$1 [QSA,L]

# todo add support for all characters allowed in a Wiki name
# make sure this is the last rule!
RewriteRule ^([-_\+A-Za-z0-9]+)$ /tiki-index.php?page=$1 [QSA,L]

RedirectMatch permanent ^/Old+Page+Name$ [mysite.com...]

ErrorDocument 500 /Error+500
ErrorDocument 404 /Error+404

<Files 403.shtml>
order allow,deny
allow from all
</Files>

-------------------------------------------

Can anyone help with this please?

jdMorgan

12:56 pm on Apr 27, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Just use a RewriteRule instead of a RedirectMatch, and place this rule immediately following "RewriteEngine on" at the top of the file:

RewriteRule ^Old+Page+Name$ http://www.example.com/New-Page-Name [R=301,L]

If you use different modules to invoke redirects, you cannot control their 'priority,' because the Apache configuration determines which module will run first. In this case, mod_rewrite may be running away with your old URLs before mod_alias ever gets a chance to run.

Jim

seosutra

1:53 pm on Apr 27, 2007 (gmt 0)

10+ Year Member



hi there,

thanks for the help... i tried this but no change in the results...

What do you mean by using different modules to redirect?

I tried to set up redirects from Cpanel, that too didnt help.

any further assistance would really be appreciated!

Thanks
seosutra

wilderness

3:26 pm on Apr 27, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



What do you mean by using different modules to redirect?

RedirectMatch is a function of the mod_alias module.
[httpd.apache.org...]

RewriteRule is a function of the mod_rewrite module.
[httpd.apache.org...]

Your server/host places precedence of these modules depending upon the order they were loaded when your server/host was booted.

BTW, some shared hosting servers offer a module load list to their customers.

seosutra

7:18 am on Apr 28, 2007 (gmt 0)

10+ Year Member



Hi,

Thanks for further information on that, i have written to my host about it and waiting for their reply.

In the meantime, is there anything else that i can try with the rewrite rule?

seosutra

9:40 am on Apr 28, 2007 (gmt 0)

10+ Year Member



hi there,

Got it to work finally... here is what i tried:

RewriteRule ^Old\+Page$ [mysite.com...] [R=301,L]

Thanks for the help!
hk