Jump to content

Strange Redirect Problem


Wes1890

Recommended Posts

:confused:

 

First off, here is the (sample) code, note that this is in wordpress, so I included the WP default htaccess code as well:

 

# View Certain Page
RewriteRule ^([a-z0-9\-]+)\/directory\/?$ 			view-directory/?directory=$1 [L,NC]


# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /path/to/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

 

 

I built a site on my localhost, and the above rewrites worked perfect. I would go to http://localhost/dir-name/directory and it would load the corresponding page (view-directory/?directory=dir-name) (which is then re-processed through the WP rewrites to display the WP page with the query string appended).

 

See how it works? Hopefully I've not lost you :)

 

Now, I transferred this to an online server, but it's not wanting to work anymore. Instead of the correct page, I get the default wordpress 404 page. If I put a fake page name for the rewrite to redirect to (something besides view-directory), then I get an actual server 404 error. So this tells me that the redirect is going through, but maybe it's not processing the wordpress portion of the rewrites? I don't know.

 

Check this out though, if I change my rewrite to:

RewriteRule ^([a-z0-9\-]+)\/directory\/?$ 			http://www.site-name.com/view-directory/?directory=$1 [L,NC]

Then the rewrite works PERFECT! The only downside to this is obviously that it redirects the URL and shows the "?" in the current page URL, we don't want that.

 

Any ideas on this? Hopefully I didn't confuse anyone. Let me know if you have questions!

 

Wes

 

 

on a side note, this (wes1890) is my old account that didn't use to work. so from now on out you'll be seeing me post as my current account "wesf90". sorry for the confusion it may cause, but i've not logged on phpfreaks in so long!

Link to comment
Share on other sites

Personally I'd bet one one of two things. Your serve uses symlinks and you don't have FollowSymLinks enabled, or perhaps more likely you have the wrong RewriteBase. Try removing the RewriteBase directive and apply a forward slash  to the start of the second half of your rule (/view-directory/...).

Link to comment
Share on other sites

I removed the RewriteBase and added the path (/) in front of the rewrite's url, but got the same results. So that rules out a rewritebase problem

 

I also turned on "Options +followsymlinks", but still got the same results as before.

 

Thanks for the reply. Any other ideas?

 

FOR CLARIFICATION:

1. DOESN'T WORK RewriteRule ^([a-z0-9\-]+)\/directory\/?$ view-directory/?directory=$1 [L,NC]

2. DOES WORK RewriteRule ^([a-z0-9\-]+)\/directory\/?$ http://www.site-name.com/view-directory/?directory=$1 [L,NC]

 

Since #2 works, we know that the WP rewrites DO WORK. The problem lies between #1 and the WP rewrites. Not sure where. When I use #1 and it leads me to WP's 404 page. On the 404 page I print_r() the _GET variables and it was empty, so there are no _GET variables being passed which is definitely causing the problem. I tried adding the "QSA" flag to the end of #1, as well as removing the "L" flag, but neither worked.

 

Wes

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.