I want to redirect (joomla - new setup, old setup has a dual language, this one only with one, and /index.php/en/[content] links not work, aliases is still same) /index.php/en/[content] to /index.php/[content]
With .htaccess rewrite, I tried few options without success.
this .htacess config redirect /index.php/en/(anypage) to /index.php/(anypage)
Options +FollowSymlinks
RewriteEngine On
RewriteRule index.php/en/(.*) index.php/$1 [R=302,L]
Based on Froggiz answer(don't worked for me):
I modified the code, and it works correctly!
Options +FollowSymlinks
RewriteEngine On
RewriteRule ^index.php/en/(.*)$ /index.php/$1 [R=301,NC,L]
Related
i have following htaccess file:
Options +FollowSymLinks
RewriteEngine on
RewriteRule !^/?(maintenance\.html|.*\.css|.*\.js)$ http://www.example.com/maintenance.html [R=302,L]
RewriteRule ^([A-Za-z0-9]+)$ $1.php
RewriteRule ^home\.php$ index.php
RewriteRule ^home$ index.php
as you can see all, no matter which page you visit on the website it will be redirected to maintenance.html. I also need a small change that will exclude one more location from this. Since I am using Magento, I need to exclude admin area from this redirect so I think these are the urls that I need
http://www.example.com/index.php/admin_852_in
http://www.example.com/skin/
http://www.example.com/js/
http://www.example.com/media/
What rule should I add for these two urls too?
thanks!
You can tweak your exclusions like this:
Options +FollowSymLinks
RewriteEngine on
RewriteRule !^/?(maintenance\.html$|index\.php/admin|css/|js/|.*\.(css|js)$) http://www.example.com/maintenance.html [R=302,L,NC]
I just transfered my Domain to a new Server. Mod_Rewrite is enabled on the new server but unfortunately some RewriteRules don't work, while others do. I haven't changed anything in the .htaccess
So the URL www.mydomain.com/go/10.html should make an internal redirect to www.mydomain.com/go.php?name=10
The snippet in the .htaccess looks like this:
# go.php
RewriteRule ^go$ "$0/" [R=301,L,QSA]
RewriteRule ^go/$ go.php [L,QSA]
RewriteRule ^go/.*?([^\.\/]*)\.html$ go.php?name=$1 [L,QSA]
The $_GET["name"] is not available if I call this url.
Replace your .htaccess code with this.
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteRule ^(go)/([^.]+)\.html$ /$1.php?name=$2 [L,QSA,NC]
I have the following htaccess:
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^models$ index.php [L]
RewriteRule ^post$ index.php?action=post [L]
and a folder named models.
The problem is: Apache sends me into the folder. With "post" the redirect rule works as there is no folder named post.
EDIT:
I forgot to tell that there is htaccess in models folder too, with:
Deny from all
If you can accept a trailing slash after models, I think this would work.
RewriteEngine On
RewriteRule ^models/?$ index.php [L]
RewriteRule ^post$ index.php?action=post& [L]
disable MultiViews in your apache configuration file.
adding "Options -MultiViews" to your .htaccess might work too.
I'm restructuring a site now, and I'm testing it on localhost (xampp).
In the root directory there were a couple of .htm files, which were converted to .php.
However I'd like to keep the .htm extension for SEO reasons.
So I created a .htaccess file with this content:
Options +FollowSymlinks
RewriteEngine On
RewriteRule ^(.*)\.php$ $1.htm [L]
But when I try to access a page like this to test rewrite:
http://localhost/sitename/anything.php
I always get to
http://localhost/C:/xampp/htdocs/sitename/anything.htm
which obviously produces a 403 error.
I have tried to change .htaccess options, but no success.
Rewrite module is enabled in Apache, so it is not the case.
Am I missing something?
Try adding a RewriteBase directive i.e.
Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteRule ^(.*)\.php$ $1.htm [L]
Try to redirect using the requested URI:
RewriteEngine On
RewriteRule ^(.*)\.php$ %{REQUEST_URI}.htm [R=301,L]
I tested it and it added ".htm" to all my php URIs test.php -> test.php.htm
No need for backreferences here.
I been using .htaccess to change php to html and it works great, but I hit a snag when I forgot that some of my static html pages in subfolders don't appear in the web browser.
Is there a way I can make it so I can only have the root folder uses the .htaccess rule and not the subfolders?
RewriteEngine on
RewriteBase /
RewriteRule ^(.*)\.html$ $1.php [L]
For this case define your .htaccess rule like this:
Options -MultiViews +FollowSymLinks
RewriteEngine On
RewriteRule ^(?![^/]+/)(.+)\.html$ $1.php [L]
Negative lookahead will prevent sub directory rule implementation.
You can specific a rule to work only on current dir. Like:
/your/dir/here/.htaccess
You .htaccess will be:
RewriteEngine on
RewriteBase /
RewriteRule ^(.*)\/here(.*)\.html$ $2.php [L]
$2 mean get second group.
Edit: alternativaly, you can make a .htaccess on subfolder and disable RewriteEngine.