Found a few similar questions but either I cant figure it out from the answers or they dont directly match my needs.
What I am trying to achieve is this:
I recently moved part of my site to a sub domain on a different server so what used to be in: http://mysite.com/clients is now on http://clients.mysite.com
using: RedirectMatch 301 https?://mysite.com/clients/^(.*)$ https://clients.mysite.com/$1 works fine for simply redirecting people hitting http://mysite.com/clients to the new sub domain however I would like to be able to preserve the string after /clients/
so if someone hits e.g. http://mysite.com/clients/could_be_a_number_of_things.php it redirects to http://clients.mysite.com/could_be_a_number_of_things.php
Can anyone advise?
full .htaccess as requested:
# -FrontPage-
IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*
<Limit GET POST>
order deny,allow
deny from all
allow from all
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
#AuthName mysite.com
#AuthUserFile /home/inhost/public_html/_vti_pvt/service.pwd
#AuthGroupFile /home/inhost/public_html/_vti_pvt/service.grp
# BEGIN WordPress
Options +FollowSymLinks -MultiViews
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteCond %{HTTPS}s on(s)|
RewriteCond %{HTTP_HOST} ^(www\.)?mysite\.com$
RewriteRule ^clients/(.*)$ http%1://clients.mysite.com/$1 [L,NC,R=301]
</IfModule>
# END WordPress
Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory on mysite.com server:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS}s on(s)|
RewriteCond %{HTTP_HOST} ^(www\.)?mysite\.com$
RewriteRule ^clients/(.*)$ http%1://clients.mysite.com/$1 [L,NC,R=301]
Related
I'm struggling with the .htaccess file. I've wordpress installed in a subdirectory 'wordpress'. In the root folder if have the htaccess with the following content:
Order Allow,Deny
Allow from all
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$
RewriteRule !^wordpress/ /wordpress%{REQUEST_URI} [L,R=301]
</IfModule>
Redirection is working, but how can I hide the subfolder 'wordpress'?
THX in advance
EDIT: Tried following content now but still not working:
root htaccess:
Order Allow,Deny
Allow from all
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com
RewriteRule !^wordpress/ wordpress%{REQUEST_URI} [L]
</IfModule>
wordpress htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /wordpress/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L]
</IfModule>
EDIT2: my whole root htaccess looks like this now:
Allow from all
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com
RewriteRule !^wordpress/ wordpress%{REQUEST_URI} [L]
If i type in www.example.com I am redirected to example/wordpress/home, example/wordpress/contact and so on...
I would like to hide the wordpress directory like example/home, example/contact and so on
Redirection is working, but how can I hide the subfolder 'wordpress'?
You shouldn't be "redirecting". You should be internally rewriting the request instead. Remove the R flag.
For example:
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com
RewriteRule !^wordpress/ wordpress%{REQUEST_URI} [L]
The slash prefix on the susbtitution string is also not required.
This assumes you have the standard WP .htaccess file in the /wordpress subdirectory.
UPDATE: Also confirm you have removed the /wordpress subdirectory from the "Website Address" and "Site Address" in WordPress General settings.
I know there are lots of similar (read: identical) questions, but I've tried everything - doesn't work.
This is my code:
Options -Indexes
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{SERVER_NAME}/$1 [L,NE,R=301]
RewriteRule ^admin/(.*)$ backend/web/$1 [L]
RewriteRule ^developers/(.*)$ api/web/$1 [L]
RewriteRule ^(.*)$ frontend/web/$1 [L]
</IfModule>
# Deny accessing below extensions
<Files ~ "(.json|.lock|.git)">
Order allow,deny
Deny from all
</Files>
# Deny accessing dot files
RewriteRule (^\.|/\.) - [F]
Everything I get is only a redirect loop.
I'm using Heroku.
Thanks.
I have php website and I have created .htaccess file. I have two rules. One for force www and other for permalink.
I want to change following Url
http://www.yatha.tv/play.php?vid=1437&id=1
to
http://www.yatha.tv/1437/1.html
But this rule does not change
RewriteRule ^([^/]*)/([^/]*)\.html$ /play.php?vid=$1&id=$2 [L]
<IfModule mod_rewrite.c>
Options +FollowSymLinks
Options +Indexes
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^yatha\.tv$
RewriteRule ^(.*)$ http://www.yatha.tv/$1 [R=301,L]
RewriteRule ^([^/]*)/([^/]*)\.html$ /play.php?vid=$1&id=$2 [L]
</IfModule>
My Setup using cPanel:
domain.com(/public_html/)
mysub.domain.com(/public_html/2013/sitepath/)
Goal: for sub2.mysub.domain.com/save-path-info to redirect to mysub.domain.com/save-path-info without change the url from sub2.mysub.domain.com. In other words, I want anysub.mysub.domain.com to be virtually the exact same as mysub.domain.com.
Code:
Options +FollowSymLinks
Options +Indexes
RewriteEngine On
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{HTTP_HOST} !^www\.2013.cqueue\.com$ [NC]
RewriteCond %{HTTP_HOST} ^(www\.)?([^\.]+)\.2013.cqueue\.com$ [NC]
RewriteRule (.*) /2013/sitepath/$1 [L]
The code above was originally in the root directory of mysub.domain.com but it wasn't working until I moved it to the root directory of domain.com. It successfully keeps the URL and path, however it is breaking the relative path of my templates.
Example: templates normally look for the path to be / but, with the rewrite above the templates think they need to look in /2013/sitepath/
EDIT
Options +FollowSymLinks
Options +Indexes
RewriteEngine On
RewriteCond %{HTTP_HOST} ^[^\.]+\.mysub\.domain\.com$ [NC]
RewriteRule ^(.*)$ http://mysub.domain.com/$1 [L]
# -FrontPage-
IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*
<Limit GET POST>
order deny,allow
deny from all
allow from all
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
AuthName domain.com
AuthUserFile /home/uadmin/public_html/_vti_pvt/service.pwd
AuthGroupFile /home/uadmin/public_html/_vti_pvt/service.grp
Try this code :
RewriteEngine On
RewriteCond %{HTTP_HOST} ^[^\.]+\.mysub\.domain\.com$ [NC]
RewriteRule ^(.*)$ http://mysub.domain.com/$1 [L]
I have content from a different server on a subdomain that I would like to use as a subdirectory. Everything from sub.domain.com should be accessible to domain.com/sub I would like sub folders to work as well ex: sub.domain.com/about should be domain.com/sub/about
Here's my current .htaccess contents
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^(sorry).* - [NC,L]
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
Any help appreciated. Thanks!
Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^sub\.domain\.com$ [NC]
RewriteRule ^ http://domain.com/sub%{REQUEST_URI} [R=301,L,NE]