homepage Welcome to WebmasterWorld Guest from 54.204.94.228
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
Complex apache redirect
Mazza




msg:1506228
 11:28 am on Jun 10, 2003 (gmt 0)

/article_info.php/name/something-something-something/cArticlePath/1/articles_id/9

should be redirected to:

/newsdesk_info.php/name/something-something-something/newsPath/1/newsdesk_id/9

in other words in url:

article_info.php >> newsdesk_info.php
cArticlePath >> newsPath
articles_id >> newsdesk_id

Anyone?

 

jdMorgan




msg:1506229
 5:12 pm on Jun 10, 2003 (gmt 0)

Mazza,

Welcome to WebmasterWorld [webmasterworld.com]!

/article_info.php/name/something-something-something/cArticlePath/1/articles_id/9

should be redirected to:

/newsdesk_info.php/name/something-something-something/newsPath/1/newsdesk_id/9

in other words in url:

article_info.php >> newsdesk_info.php
cArticlePath >> newsPath
articles_id >> newsdesk_id


Something like this should work in .htaccess. If you are adding this to httpd.conf, start the pattern with "^/article" - i.e., add a preceding slash.

RewriteRule ^article\_info\.php/name/(.+)/cArticlePath/(.+)/articles\_id/(.+)$ /newsdesk_info.php/name/$1/newsPath/$2/newsdesk_id/$3 [L]

Ref: Introduction to mod_rewrite [webmasterworld.com]

HTH,
Jim

Mazza




msg:1506230
 9:04 am on Jun 11, 2003 (gmt 0)

Thank you Jim for trying to help. The code however does not seem to have any effect. I would gues the problem is with me not knowing how to use it. Heres a sample of the subdomain rigth above the section where I inserted the code:

RewriteEngine On
Options +FollowSymlinks
RewriteBase /
# Alidomain
RewriteCond %{HTTP_HOST} testing.mydomain.net$
RewriteCond %{REQUEST_URI}!shop/
RewriteRule ^(.*)$ shop/$1

RewriteEngine On
Options +FollowSymlinks
RewriteBase /
RewriteRule ^article\_info\.php/name/(.+)/cArticlePath/(.+)/articles\_id/(.+)$ /newsdesk_info.php/name/$1/newsPath/$2/newsdesk_id/$3 [R=301,L]

It is in an htaccess file on a shared server. But it should work since the subdomains are working , rigth?

Also none of the files are in the root but have sub domains on them like:

RewriteEngine On
Options +FollowSymlinks
RewriteBase /
# Alidomain
RewriteCond %{HTTP_HOST} www.mysite.net$
RewriteCond %{REQUEST_URI}!catalog2/
RewriteRule ^(.*)$ catalog2/$1

jdMorgan




msg:1506231
 5:02 pm on Jun 11, 2003 (gmt 0)

Mazza,

Apologies for the delay - I suspect we're on opposite sides of the world...

I'll have to get back to you on this, but I do see something that may need to be fixed: You have multiple occurrences of Options, RewriteEngine, and RewriteBase directives in your file, and they are in the wrong order.

Place this sequence before any RewriteCond or RewriteRule directives, and include it in each .htaccess file only once:

Options +FollowSymLinks
RewriteEngine on
RewriteBase /

In addition, none of your existing rules have an [L] flag on them, which means the RewriteEngine will continue to process all rewrite rules for all requests, even after applying a rewrite. In most cases, this won't cause problems other than slowing down your server slightly, but realize that if the output URL from one rewriterule matches the pattern of a following rule, then the URL will be rewritten again.

The pattern on the left side of the rule I sent you will match only if your .htaccess file is in a directory that has a subdirectory named "/article". If this is not true, then the code will do nothing.

I'll look at your post again when I get back and see if I can spot anything else wrong. In the meantime, perhaps one of the points above may help, and you might wish to spend some time studying the post I cited above, and the information linked from that post.

HTH,
Jim

Mazza




msg:1506232
 7:15 pm on Jun 12, 2003 (gmt 0)

No problem, Jim. I am not on a deadline. Would just like to drop the old article management system from my site. And now thanks to you, we can.

Moving the rewrite to a new htaccess file and moving it to the same folder as the files did the trick. And by modifying it I found a way to do three more similar redirects. Thank you for your help. I really appreciate it.

jdMorgan




msg:1506233
 9:54 pm on Jun 12, 2003 (gmt 0)

Mazza,

Glad that worked out! I had to take a break from WebmasterWorld and actually do some work over the past couple of days! :)

Jim

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved