Jump to content

Header Location Redirect + Mod Rewrite


shanejeffery86

Recommended Posts

Hey all.

 

I currently am redirecting to another PHP file via a header redirect.  Upon that header redirect, I need a rewrite to be done.

 

How do I do this?

 

header("Location: armory.php?profileID=" . $profileID);
exit;

 

Hits the armory page and then this rule takes affect in the .htaccess file:

 

RewriteRule wow-armory-profile/(.*) armory.php?profileID=$1

 

Is it even possible to do this?  If not, please let me know and as I am going to have to move around quite a lot of code to make this work correctly for rewriting.

Link to comment
https://forums.phpfreaks.com/topic/204816-header-location-redirect-mod-rewrite/
Share on other sites

Doing further research, I think I figured out a possible solution:

 

RewriteCond %{QUERY_STRING} ^profileID=([0-9]*)$

RewriteRule wow-armory-profile/(.*) /armory.php?profileID=%1 [L]

 

So, if we find the profileID in the condition, we execute the rewrite rule below.

Hey Alex.

 

The problem with that is that location does not correspond to anything.  I want the armory.php to be hit when the Location you have listed is hit ("Location: wow-armory-profile/" . $profileID).  How do I go about doing that?

 

So, when I redirect to "wow-armory-profile/" . $profileID", I want the armory.php to recognize that it needs to run, but I want to keep the URL as "wow-armory-profile/" . $profileID".

 

I painted myself into quite a corner here and having trouble getting out.

 

Thanks.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.