I want to write a RewriteRule to another RewriteRule, but I can't seem to get things to work. I'm having troubel with the line
RewriteRule ^(eTool/)?(RENDER/\d+/\d+/\d+/\d+\.html)$ render-product?url=$2 [L,NC]
in this file:
RewriteEngine On
RewriteBase /
RewriteRule ^(eTool/)?(RENDER/\d+/\d+/\d+/\d+\.html)$ render-product?url=$2 [L,NC]
#uploaded files
RewriteRule ^(.*/)?files/$ index.php [L]
RewriteCond %{REQUEST_URI} !.*wp-content/plugins.*
RewriteRule ^(.*/)?files/(.*) wp-content/blogs.php?file=$2 [L]
# add a trailing slash to /wp-admin
RewriteCond %{REQUEST_URI} ^.*/wp-admin$
RewriteRule ^(.+)$ $1/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule . - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-.*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]
Basically, the url render-product is a url frendly url created by wordpress. I want something like ?url=RENDER/34324/4234/234234.html to be accessible on the wordpress page render-product via $_GET['url'].
What am i doing wrong?
RewriteRule ^(eTool/)?(RENDER/\d+/\d+/\d+/\d+\.html)$ index.php?pagename=render-product&url=$2 [L,NC]
I've suggested rewriting the URL to WP as query parameters, since WP won't parse the permalink of the rewrited URL, it will only examine the original URI request (if that makes sense!?).
Related
Hi i have a wordpress site with two subdirectories:
example.com/forum
example.com/shop
I need to display example.com/forum on subdomain like this: forum.example.com, and simmilar with /shop
I try to do this by modyfing htaccess, but no results.
The code i was added looks like this:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^forum.example.com
RewriteRule ^(.*)$ http://example.com/forum/$1 [L,NC,QSA]
So the whole htacces looks like this:
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
# add a trailing slash to /wp-admin
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^(.*\.php)$ $1 [L]
RewriteRule . index.php [L]
RewriteEngine on
RewriteCond %{HTTP_HOST} ^forum.example.com
RewriteRule ^(.*)$ http://example.com/forum/$1 [L,NC,QSA]
But this not working.
Also i have redirect my subdomains to subdirectories on the serwer, do i need to copy htaccess to those subdirectories?
Sorry for my bad english
I do not usually in the habit of posting , because I always find my answer by searching the forums , but today I came across a real problem !
I have a Wordpress install multisite in a subdirectory of my domain. That is to say, it is at http://mondomaine.com/fr/ .
I wish to make a mobile version in a subdomain "m . " I want my mobile version is available at http://m.mondomaine.com/fr/ .
My host has created the subdomain m that points to the root of the site.
When I want to access a page from my mobile subdomain redirects it necessarily to the homepage /fr/ .
I tried to change my .htaccess , But nothing could be done , or I have a redirect loop , or I have a 404 page.
I suppose that there is a conflict between the rules , but I really tried and tested lots of solutions and I found nothing conclusive.
The original htaccess generated by Wordpress and located in the directory /fr :
RewriteEngine On
RewriteBase /fr/
RewriteRule ^index\.php$ - [L]
# uploaded files
RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]
# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^[_0-9a-zA-Z-]+/(.*\.php)$ $1 [L]
RewriteRule . index.php [L]
.htaccess that I modified:
RewriteEngine On
RewriteBase /fr/
RewriteRule ^index\.php$ - [L]
# uploaded files
RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]
# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^[_0-9a-zA-Z-]+/(.*\.php)$ $1 [L]
RewriteCond %{HTTP_HOST} !^m\.(.*) [NC]
RewriteRule . index.php [L]
RewriteCond %{HTTP_HOST} ^m\.(.*) [NC]
RewriteRule ^(.*)$ http://mondomaine.com/fr/$1 [L,P]
Thank you in advance to those who respond
If mod_proxy is enabled then move last m. rule right at the top, just below RewriteEngine On as this:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^m\.(.+)$ [NC]
RewriteRule ^(.*)$ http://mondomaine.com/fr/$1 [L,P]
I have a WordPress multisite (using subfolders, not subdomains) in the format domain.com. For reasons of consistency and better SEO, I'd like to forward it to www.domain.com.
I've tried putting this code into .htaccess but I get a redirect loop:
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
# this is the code I added to forward to www
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]
I'm pretty sure my domain is set to without www in the WordPress settings but it won't let me see that any more now I have a multisite.
I would try first not using htaccess redirect and remove the www redirect you have. Then edit your wp-config.php and change the DOMAIN_CURRENT_SITE to be your www domain. This way wordpress will handle the redirection.
Or you can try the htaccess method, but you might have some order problems, I believe with MU, the redirect needs to be the first thing. Replace domain.com with your real site.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain.com$ [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]
RewriteBase /
RewriteRule ^index\.php$ - [L]
# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]
I have a Wordpress network setup but currently there is only one subsite with the url
/psychology
In the future there will be addition sites with
/md
/vet
but for the time being there will only be /psychology
What I want to do is have a rewrite rule in my htaccess that when a user visits the root of the site (/) it actually loads the /psychology site.
I tried adding a line like this to my htaccess
RewriteRule (.*) psychology/$1 [R,L]
but it broke the site. here is my current htaccess (basically the wordpress default for a network install)
# BEGIN WordPress
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
RewriteBase /ASKanALLY/
RewriteRule ^index\.php$ - [L]
# uploaded files
RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]
# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^[_0-9a-zA-Z-]+/(.*\.php)$ $1 [L]
RewriteRule . index.php [L]
</IfModule>
# END WordPress
Any ideas?
You need to add the base to the RewriteRule destination. And add a condition so you don't get a redirect loop.
Adding these two lines after RewriteRule ^ - [L] should work:
RewriteCond %{REQUEST_URI} !^/ASKanALLY/psychology ## Not already viewing a psychology URL
RewriteRule ^(.*)$ /ASKanALLY/psychology/$1 [R,L] ## Redirect to psychology
Here's the complete example:
# BEGIN WordPress
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
RewriteBase /ASKanALLY/
RewriteRule ^index\.php$ - [L]
# uploaded files
RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]
# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteCond %{REQUEST_URI} !^/ASKanALLY/psychology ## Not already viewing a psychology URL
RewriteRule ^(.*)$ /ASKanALLY/psychology/$1 [R,L] ## Redirect to psychology
RewriteRule ^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^[_0-9a-zA-Z-]+/(.*\.php)$ $1 [L]
RewriteRule . index.php [L]
</IfModule>
Your RewriteRule didn't work because it was matching all URLs, including ones to /psychology/foo. I'm guessing you don't have a .htaccess file under /psychology?
Try this - it'll rewrite just the root.
RewriteRule ^/$ psychology/ [r=301,L]
I'm having a minor but annoying issue with a site running WordPress 3.1.4 Multisite.
Navigating to the URI of a subpage without the "http://www" such as "abetterworldbydesign.com/2011-conference/" results in a redirect to the root "http://www.abetterworldbydesign.com".
The intent is for "abetterworldbydesign.com/2011-conference/" to redirect to "http://www.abetterworldbydesign.com/2011-conference/".
.htaccess file below (it's specific stuff for WordPress Multisite).
# BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
# uploaded files
RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]
# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^[_0-9a-zA-Z-]+/(.*\.php)$ $1 [L]
RewriteRule . index.php [L]
# END WordPress
Try adding this
RewriteCond %{HTTP_HOST} ^abetterworldbydesign.com
RewriteRule ^(.*)$ http://www.abetterworldbydesign.com/$1 [R=301,L]
at the very top, just after RewriteEngine On.