Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

- - - - -

htaccess redirect doesn't work

redirect

  • Please log in to reply
24 replies to this topic

#13 semprance

semprance

    CC Addict

  • Just Joined
  • PipPipPipPipPip
  • 118 posts

Posted 20 April 2010 - 03:31 AM

Sorry dude, I have no idea what it could be, your .htaccess looks fine to me. Here's how I have it exactly:

RewriteCond %{QUERY_STRING} /topic/114-php-and-xml/
RewriteRule ^forum/index.php$ http://mysite.com/forum/php/31-php-xml.html? [L,R=301] 

That's copied straight from my file and when I go to http://www.sitename....114-php-and-xml, it redirects me to the mysite.com address. I have no idea why it aint working for you (especially considering that its the first rewrite in the file!)
  • 0

#14 semprance

semprance

    CC Addict

  • Just Joined
  • PipPipPipPipPip
  • 118 posts

Posted 20 April 2010 - 03:39 AM

Just to check, this .htaccess file is in your root directory isn't it? And not the /forum directory?
  • 0

#15 SoN9ne

SoN9ne

    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 118 posts
  • Programming Language:Java, PHP, JavaScript, Bash
  • Learning:C, Objective-C

Posted 20 April 2010 - 06:25 AM

This works on my dev server

I added the extra check to ensure all pages get redirected with and without the ending /
RewriteCond %{QUERY_STRING} ^/topic/114-php-and-xml [OR]
RewriteCond %{QUERY_STRING} ^/topic/114-php-and-xml/
RewriteRule ^forum/index\.php$ /forum/php/31-php-xml.html? [L,R=301]

  • 0
"Life would be so much easier if we only had the source code."

#16 Guest_Jaan_*

Guest_Jaan_*
  • Guest

Posted 22 April 2010 - 08:38 PM

No man.. I have my htaccess in my "forum" folder and this script doesn't work :/
  • 0

#17 semprance

semprance

    CC Addict

  • Just Joined
  • PipPipPipPipPip
  • 118 posts

Posted 23 April 2010 - 01:31 AM

Ok, well the paths relative unless you add "RewriteBase /" which will make the htaccess act as if you are at root. However, that will likely just mess up all the other redirects in the file, unless you use RewriteBase again.

Try the following instead, I'm almost 100% certain this will work:

RewriteCond %{QUERY_STRING} /topic/114-php-and-xml/
RewriteRule ^index.php$ http://mysite.com/forum/php/31-php-xml.html? [L,R=301]

  • 0

#18 Guest_Jaan_*

Guest_Jaan_*
  • Guest

Posted 26 April 2010 - 10:52 AM

No man.. it doesn't work. :/
  • 0

#19 SoN9ne

SoN9ne

    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 118 posts
  • Programming Language:Java, PHP, JavaScript, Bash
  • Learning:C, Objective-C

Posted 26 April 2010 - 12:32 PM

Try this
RewriteCond %{QUERY_STRING} ^/topic/114-php-and-xml [OR]
RewriteCond %{QUERY_STRING} ^/topic/114-php-and-xml/
RewriteRule ^(.*)$ /forum/php/31-php-xml.html? [L,R=301]

  • 0
"Life would be so much easier if we only had the source code."

#20 semprance

semprance

    CC Addict

  • Just Joined
  • PipPipPipPipPip
  • 118 posts

Posted 26 April 2010 - 01:58 PM

That's much more robust :-) Although it will redirect everything in the /forum folder rather than just index.php

Still definitely worth trying though.
  • 0

#21 SoN9ne

SoN9ne

    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 118 posts
  • Programming Language:Java, PHP, JavaScript, Bash
  • Learning:C, Objective-C

Posted 26 April 2010 - 05:09 PM

RewriteCond %{QUERY_STRING} ^/topic/114-php-and-xml [OR]
RewriteCond %{QUERY_STRING} ^/topic/114-php-and-xml/


far from everything
  • 0
"Life would be so much easier if we only had the source code."

#22 semprance

semprance

    CC Addict

  • Just Joined
  • PipPipPipPipPip
  • 118 posts

Posted 27 April 2010 - 01:34 AM

Ok, well, everything with either of those query strings
  • 0

#23 SoN9ne

SoN9ne

    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 118 posts
  • Programming Language:Java, PHP, JavaScript, Bash
  • Learning:C, Objective-C

Posted 27 April 2010 - 05:14 AM

^^

this would be better I suppose, although I don't see it being a big deal since the URLs are known but I understand the dilemma it could impose.

RewriteCond %{QUERY_STRING} ^/topic/114-php-and-xml/? [NC]
RewriteRule ^index.php$ /forum/php/31-php-xml.html? [L,R=301]


Of course, [NC] is optional

Edited by SoN9ne, 27 April 2010 - 06:50 AM.
Used /? instead of OR and added NC

  • 0
"Life would be so much easier if we only had the source code."

#24 Guest_Jaan_*

Guest_Jaan_*
  • Guest

Posted 27 April 2010 - 10:18 AM

Daaaaaaaaaaaaaaaaaaaaaaayum man :D it works!!! :D awesome.. send me your paypal address :D
  • 0





Also tagged with one or more of these keywords: redirect

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download