I want to simply point the www.mysite.com/corporate to www.mysite.com/services/corporate
here is my .htaccess:
#DirectoryIndex index.php index.html
#Options +FollowSymLinks
#Options -Indexes
#ErrorDocument 403 default
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^corporate$ services/corporate
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.+) - [PT,L]
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(.*) index.php
RewriteCond %{HTTP:Authorization} !^$
RewriteRule .* - [E=REMOTE_USER:%{HTTP:Authorization}]
</IfModule>
#php_value register_globals 0
Use mod_rewrite. Place something like this in .htaccess in the root directory:
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^(.*)/corporate/(.*)$ $1/services/corporate/$2 [R,L]
See http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html for more info.
Difficult to understand some parts of your .htaccess code but you can add one more line before </IfModule> there:
RewriteRule ^corporate/?$ services/corporate [NC,L,R=301]
Related
I am using CodeIgniter 4.1.3.
below is my .htaccess
#Options All -Indexes
<IfModule mod_rewrite.c>
#Options +FollowSymlinks
RewriteEngine On
# RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([\s\S]*)$ index.php/$1 [L,NC,QSA]
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 index.php
</IfModule>
ServerSignature Off
options all and followSymlinks not supported on server.
Working fine on localserver
Front page is loaded but it is not loading css,javascript and image from public directory giving 404 error.
not sure what need to be change.
With your shown samples, please try following htaccess Rules file. Make sure to place this in your root directory. Also make sure to clear your browser cache before testing your URLs.
Options -Multiviews
<IfModule mod_rewrite.c>
#Options +FollowSymlinks
RewriteEngine On
RewriteBase /public/
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/?$ index.php/$1 [L,NC,QSA]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 index.php
</IfModule>
ServerSignature Off
JS/CS rewrite/redirect: You may need to use base tag to fix your js and other relative resources. If you are linking js files using a relative path then the file will obviously get a 404 because its looking for URL path. for example if the URL path is /file/ instead of file.html then your relative resources are loading from /file/ which is not a directory but rewritten html file. To fix this make your links absolute or use base tag. In the header of your webpage add this <base href="/"> so that your relative links can load from the correct location.
Options All -Indexes
Options +FollowSymlinks
works well on apache but if your server is centos then use this
Options -Indexes
Options +SymLinksIfOwnerMatch
I try actually to change my url => www.mysite.com to www.mysite.com/fr/ and i have to use my .htaccess for that.
So i changed my .htaccess from my root like that:
SetEnv SHORT_OPEN_TAGS 0
SetEnv REGISTER_GLOBALS 0
SetEnv MAGIC_QUOTES 0
SetEnv SESSION_AUTOSTART 0
SetEnv ZEND_OPTIMIZER 1
SetEnv PHP_VER 5_3
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ web/$1 [QSA,L]
RedirectPermanent / http://www.chat.com/fr/
</IfModule>
and i have my /web/.htaccess like that:
DirectoryIndex app.php
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^app\.php(/(.*)|$) %{ENV:BASE}/$2 [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule .? - [L]
RewriteRule .? %{ENV:BASE}/app.php [L]
</IfModule>
<IfModule !mod_rewrite.c>
<IfModule mod_alias.c>
RedirectMatch 302 ^/$ /app.php/
</IfModule>
</IfModule>
and when i try to upload my site, i have this url : www.mysite.com/fr/fr/fr/fr/... and an error. Someone can help me ? :(
Your rules will indeed cause a redirect loop. Try this in root .htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^/?$ /fr/ [L,R]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ web/$1 [L]
</IfModule>
Make sure to test this after clearing your browser cache.
I want to redirect all sub directories under sub directory root/windows/ to root/windows/ct.php
File structure of site is like
root/windows/ct.php
Redirect these type of url
http://www.site.com/windows/games/ or http://www.site.com/windows/games
http://www.site.com/windows/software/ or http://www.site.com/windows/software
To
http://www.site.com/windows/ct.php?ct=games
http://www.site.com/windows/ct.php?ct=software
I am trying like this but it redirects all url to sub directory root/windows/ct.php
RewriteRule ^([^/]*)/ /Site/windows/?ct=$1 [L]
RewriteRule ^([^/windows]*)/ /Site/windows/?ct=$1 [L] // this one shows internal server error
Complete .htaccess code
Options +FollowSymlinks
RewriteEngine on
<IfModule mod_rewrite.c>
RewriteRule ^(error) - [L]
RewriteRule ^[^/]*/[^/]*/(.*\.html) /Site/error/400/ [L]
RewriteRule ^([^/]*)/(.*\.html) /Site/software/?link=$1&id=$2 [L]
RewriteRule ^([^/]*)/ /Site/windows/?ct=$1 [L]
RewriteRule ^sitemap\.xml$ sitemap.php [L]
RewriteRule ^rss/(.*?)\.xml$ rss/$1.php [L]
</IfModule>
ErrorDocument 400 /Site/error/400/
I do not know well about .htaccess please see and suggest any possible way to do it.
Thanks.
Give this a try:
<IfModule mod_rewrite.c>
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^windows/([^/]+)/?$ /windows/ct.php?ct=$1 [L]
</IfModule>
For your localhost use this one:
<IfModule mod_rewrite.c>
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /Site/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^windows/([^/]+)/?$ windows/ct.php?ct=$1 [NC,L]
</IfModule>
I have a lithium installation and all the .htaccess works fine.
I need to install OpenCart as a shopping cart in app/webroot/shop
I copied all the files and also changed the .htaccess file in the root folder of lithium installation as
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteRule shop/(.*) /app/webroot/shop/$1 [L]
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
Still when I browse http://domain.com/shop it takes me to http://domain.com/app/webroot/shop/
With an error on page:
Exception
lithium\action\DispatchException (code 404)
Action `webroot` not found.
Please help me in solving this problem.
You may try this instead:
<IfModule mod_rewrite.c>
Options +FollowSymlinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !/app/webroot/shop/? [NC]
RewriteRule ^shop/(.*) /app/webroot/shop/$1 [L,NC]
RewriteCond %{REQUEST_URI} !/app/webroot/? [NC]
RewriteRule ^$ /app/webroot/ [L,NC]
RewriteCond %{REQUEST_URI} !/app/webroot/? [NC]
RewriteRule ^(.*) /app/webroot/$1 [L,NC]
</IfModule>
The problem is that your last "catch all" rule is also redirecting all requests for the shop to lithium, which you don't want.
Try this
Options +FollowSymlinks -MultiViews
RewriteEngine On
# Rewrite all URLs that start with /shop to /app/webroot/shop
RewriteRule ^shop/.? /app/webroot/shop%{REQUEST_URI} [L]
# Rewrite all URLs that don't start with /app/webroot/shop to /app/webroot
RewriteCond %{REQUEST_URI} !^/app/webroot/shop
RewriteRule .? /app/webroot%{REQUEST_URI} [L]
This is the rewrite rule does not working in .htaccess:
RewriteCond %{REQUEST_URI} ^/magento/resultados-busqueda/
RewriteRule resultados-busqueda/(.*) /magento/index.php/catalogsearch/result/$1 [L,QSA,NC]
If I add [R] flag, it's work fine, but without [R] does not work.
Please help!!
Sorry for my english.
Thank you!
It turns out that the new Apache version has changed in some way, if you are using apache 2.4, I suggest you to change your etc/apache2/apache2.conf file (you'll need root permission) as follows:
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
Then restart apache.
sudo service apache2 restart
It works ;)
Use below .htaccess snippet in your $DOCUMENT_ROOT/magento/.htaccess:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /magento
RewriteRule ^resultados-busqueda/([^/]+)/?$ /magento/index.php/catalogsearch/result/?q=$1 [QSA,P,NC]
URI domain/magento/resultados-busqueda/pantalones and show error 404.
This my .htaccess:
<IfModule mod_rewrite.c>
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /magento
RewriteRule ^api/rest api.php?type=rest [QSA,L]
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{REQUEST_METHOD} ^TRAC[EK]
RewriteRule .* - [L,R=405]
RewriteCond %{REQUEST_URI} !^/(media|skin|js)/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^resultados-busqueda/(.*)$ /magento/index.php/catalogsearch/result/?q=$1 [L,NC]
RewriteRule .* index.php [L]