I'm having troubles solving a redirection issue in wordpress since i've wanted to use a different domain that's pointed to the original url.
Original URL is: http://me.myfirstdomain.com/project/wp Pretty Urls I'm Using: http://me.myfirstdomain.com/project/wp/categoryname/this-is-a-post/
What I'm trying to acchive is that http://www.mynewurl.com/categoryname/this-is-a-post/ lead me to http://me.myfirstdomain.com/project/wp/categoryname/this-is-a-post/ But this would lead me to a 404 Error :-'(
I'm using the custom permalink structure: /%category%/%postname%/
When using default permalink structur开发者_开发知识库e like http://me.myfirstdomain.com/project/wp/?p=123 everything works fine, but i'm doing some queries to an API through the URL so the "pretty" permalinks are obligatory.
Check to make sure that mod_rewrite is on. If it is, and Wordpress has write permissions in the directory it's installed in, it will write it's own .htaccess file.
I've run across an issue with .htaccess redirects and wordpress that may be what's going on with your site. When you use "pretty permalinks", wordpress adds the following code to your .htaccess file:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
I added a few 301 redirects to my .htaccess file and for some reason they weren't working. I double checked, then triple checked the code and still nothing. Finally, I stumbled across a solution. If I put the 301 redirects BEFORE the "# BEGIN WordPress" then they worked fine. It was only when they came after the wordpress rewrite code that the redirects didn't work.
This may be the same issue that you're seeing, so my suggestion is to try editing your .htaccess file so the re-direct code comes BEFORE the wordpress rewrite code. Like this:
RewriteCond %{HTTP_HOST} ^.*$
RewriteRule ### [YOUR REDIRECT CODE HERE] ###
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Hope that helps!
精彩评论