Forum Moderators: phranque

Message Too Old, No Replies

301 ASP to PHP URLS

301 ASP to PHP URLS

         

whyyi

4:18 am on Sep 22, 2009 (gmt 0)

10+ Year Member



Hi All,

I'm working on an x-cart project and currently have an seo plug in installed however I think it may be conflicting with trying to re-direct the old asp urls to the new php urls. I'm racking my brain over why the below isn't working. The below won't redirect the old asp url to the new php url it will just bring up a page not found at the old asp url.

RewriteEngine On

RewriteCond %{REQUEST_URI} !^/(payment地dmin如rovider如artner)/
RewriteCond %{REQUEST_FILENAME} !\.(gif夸pe?g如ng夸s圭ss存wf如hp夷co)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.+)$ cdseopro.php

RewriteCond %{QUERY_STRING} &?ID=50&?
RewriteRule ^aboutus_articles.\.asp$ [exampleurl.com...] [R=301,L]

Any help is greatly appreciated. Thanks!

jdMorgan

1:05 pm on Sep 22, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It's likely that the problem is that your two rules are reversed. The second rule will never run unless the requested URL-path resolves to an existing file, directory, or symlinked path which does not start with payment/, admin/, provider/, or partner/, and is not an image, js, css, swf, or php file.

The first rule will therefore rewrite requests for "aboutus_articles.asp" URL-paths to cdseopro.php, which the second rule will not redirect because it no longer matches the second rule's pattern.

Your first rule is also missing an [L] flag, which I recommend in all cases unless you *know* why you wish to omit it.

In general, order your rules with all external redirects first, in order from most-specific patterns and conditions to least-specific, followed by all internal rewrite, again in order from most-specific patterns and conditions to least-specific. If you implement access control rules, these generally should precede all other rules, since there is no use wasting time or CPU resources on redirecting or rewriting unwelcome requests.

Jim

whyyi

4:00 pm on Sep 22, 2009 (gmt 0)

10+ Year Member



Hi Jim,

Thanks for the quick reply. It makes sense but I just can't seem to get it to work. I switched the two rules and even tried to have the requested url-path resolve to a random url like http://www.example.com/test.psd and still no luck.

Thanks for the help greatly appreciated!

jdMorgan

5:45 pm on Sep 22, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You also may have a problem with your new rule's pattern, unless it was just a typo when posting here. The pattern should likely be: "^aboutus_articles\.asp$" and not "^aboutus_articles.\.asp$"

The current pattern will match only if *any* single character appears after "aboutus_articles" and before ".asp", as in "/aboutus_articlesX.asp" -- probably not what you intended.

Jim

whyyi

10:36 pm on Sep 23, 2009 (gmt 0)

10+ Year Member



Hi Jim,

Thank you your absolutely right it was a typo. I just fixed the typo and put the external re-directs first and worked like a charm.

Thank you so much! I really really appreciate the help.