I'm in this situation
http://example.com/sub-domain/
and I wish to have this
http://example.com/sub/domain/
without loosing in SEO, what's the right RewriteRule?
At the moment this is my .htaccess file in the subdomain DOCUMENT_ROOT
Options -Indexes +FollowSymLinks
RewriteEngine On
RewriteBase /sub-domain/
# exclude any paths that are not codeigniter-app related
RewriteCond %{REQUEST_URI} !^/server-status
RewriteCond %{REQUEST_URI} !^/server-info
RewriteCond %{REQUEST_URI} !^/docs
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
<IfModule mod_php5.c>
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
# the following is for rewritting under FastCGI
<IfModule !mod_php5.c>
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
EDIT
In my root domain I have installed Wordpress and this is the .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{ENV:REDIRECT_STATUS} 200
RewriteRule .* - [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 [QSA,L]
</IfModule>
Leave /sub-domain/.htaccess as is. And have this rule in root .htaccess (a level above /sub-domain/):
RewriteEngine On
RewriteCond %{THE_REQUEST} /sub-domain(\S*)\s [NC]
RewriteRule ^ /sub/domain%1? [R=301,L,NE]
RewriteRule ^sub/domain(/.*)?$ sub-domain$1 [L,NC]
Related
htaccess in root folder
#<IfModule mod_rewrite.c>
#RewriteEngine On
#Uncomment these two lines If you want to redirect http to https
#RewriteCond %{HTTPS} off
#RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule ^(.*)$ index.php [L]
#</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^https://3pmix.com/ [NC]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
</IfModule>
htaccess in sub folder
RewriteRule ^classes/.*$ - [F,L]
RewriteCond %{HTTPS} off
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{REQUEST_URI} config.php|db.php|functions.php [NC]
RewriteRule .* - [F,L]
directory structure through images
With your shown samples, please try following Rules file. Also make sure to clear your browser cache before testing your URLs.
Have your root htaccess Rule file like as follows:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^3pmix\.com [NC]
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NE]
</IfModule>
And have your sub directory htaccess Rules file as follows:
RewriteOptions InheritBefore
RewriteEngine ON
RewriteRule ^classes - [NC,F,L]
RewriteRule (?:config\.php|db\.php|functions\.php) - [NC,F,L]
I have also fixed flags and regex in your htaccess files.
Rewrite base was missing that is why was not finding the root url of the website
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [L]
</IfModule>
I want to have only URLs with trailing slash on my website. At the moment I have only URLs without trailing slash. How I have to modify my htaccess?
Here it is:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)/[0-9]+$ %{REQUEST_URI}/ [QSA,L,R=301]
RewriteRule ^unternehmen-2-2/?$ /unternehmen [L,R=301,NC]
RewriteRule ^expose/(.*)/$ content/index.php?content=expose&query=$1 [L,QSA]
</IfModule>
# 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 hope somebody can help me.
You can use these rules above default wordpress .htaccess:
RewriteEngine On
RewriteBase /
# add trailing slash too all URLs
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.*?[^/])$ %{REQUEST_URI}/ [L,R=301,NE]
RewriteRule ^unternehmen-2-2/?$ /unternehmen/ [L,R=301,NC]
RewriteRule ^expose/(.*)/$ content/index.php?content=expose&query=$1 [L,QSA]
Is it fine to have two RewriteEngine On rules in the .htaccess file, like here? Wordpress added automatically the new module.
Also, is it necessary to have the double RewriteBase / rules? Files are in the root directory.
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# 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
it would not harm, second call would be ignored, but you might as well edit file and clean up:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# WordPress
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
I have Magento installed in a subdirectory, the path to Magento is example.com/magento.
I have an .htaccess file in the root, 'example.com' as follows:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{http_host} ^example.com [NC]
RewriteRule ^magento/(.+)$ http://www.example.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$ [NC]
RewriteCond %{REQUEST_URI} !^/magento(/.*)?$ [NC]
RewriteRule ^(.*)$ /magento/$1 [QSA,L]
In the standard Magento .htaccess in example.com/magento I have uncommented the RewriteBase directive as follows:
RewriteBase /magento/
But when I type example.com the browser shows example.com/magento
How could I solve this issue?
Leave RewriteBase commented
# RewriteBase /magento/
Try this, instead, in your /.htacccess:
RewriteEngine on
RewriteRule ^(.*)$ /magento/$1 [L]
RewriteRule ^(.*)$ /index.php/$1 [L]
and add this to your magento/.htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . / [L]
</IfModule>
i have 2 domains:
- domain1.org
- domain2.org
i have installed wordpress in http://domain1.org/wordpress and i need that users enter with http://domain2.org
Currently my htaccess is(based on other posts readed here):
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^(www.)?domain2\.org$ [NC]
RewriteRule ^(.*)$ http://www.domain1.org/wordpress/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php [L]
</IfModule>
this works but always show in the links the domain1 url:
http://domain1.org/wordpress/category/furniture/
and in the browser bar i have http://www.domain2.org
Is the htaccess wrong? i have domain2 with godaddy and i'm doing a masked forward.Maybe i should park it?
thk.
# BEGIN WordPress
<IfModule mod_rewrite.c>
# tell mod_rewrite to activate and give base for relative paths
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^(www.)?PARKED.com$
RewriteCond %{REQUEST_URI} !^/PARKED/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /PARKED/$1
RewriteCond %{HTTP_HOST} ^(www.)?PARKED.com$
RewriteRule ^(/)?$ PARKED/index.php [L]
# for main domain
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 . index.php [L]
</IfModule>
# END WordPress