Rewrite rule doesn't work on joomla htaccess - .htaccess

I need a redirect from http://www.mysite.com/passport/365.html to http://www.mysite.com/passport/365.html?task=view
I try to do it like this
RewriteCond %{HTTP_HOST} ^/passport/365.html$
RewriteRule ^/?$ /passport/365.html?task=view [QSA]
and it doesn't work.
Please help.

try that :
RewriteEngine on
RewriteRule ^passport/365\.html$ http://www.mysite.com/passport/365.html?task=view [R]
I think in you example ur missing the **
so it should be something like :
RewriteRule ^/passport/365\.html$ /passport/365\.html?task=view [QSA]

I would recommend you use this plugin.
You can simply add the redirect rule to the plugin without modifying .htaccess

There is a component already build in Joomla called "redirect" where U can set-up your redirects, so you don't have to use .htaccess at all.
Here is a good tutorial: http://www.joomtraining.com.au/tutorials/joomla-1.6/creating-a-page-redirect
The problem with the .htaccess is that every redirect must be set in appropriate place in the file.

Related

htaccess to remove part of a url, .htaccess

I was wondering how it is possible to remove part of a url with htaccess for example I have a url like this:
http://localhost/item.php?pa=gd34392
now I need to use htaccess to redirect this page or anything like this to a page with this url:
http://localhost/gd34392
I have tried things like this but nothing seems to work and I do not really know my way around htaccess
RewriteEngine on
RewriteRule item.php?pa=$1 /$1 [R=301,L]
You can achieve that using the following rules in your .htaccess:
RewriteEngine On
RewriteRule ^([^/]*)$ /item.php?pa=$1 [L]
Just make sure you clear your cache before testing this.

URL Rewrite is not working correctly in .htaccess

I am trying to create a rewrite in my .htaccess file for my wordpress site. I need
www.a3performance.com/fastestsuit
to point to
http://www.a3performance.com/legend-fastest-racing-suit/
I am trying this, but it doesn't seem to work?
RewriteRule ^fastestsuit/?$ legend-fastest-racing-suit [NC,L]
Seems that you need to use here Redirect from one folder to new folder.
Something like this:
RewriteRule ^subdirectory/(.*)$ /anotherdirectory/$1 [R=301,NC,L]
Actually #labris idea worked. For some reason it took a bit for my server to register the .htaccess change.
RewriteRule ^subdirectory/(.*)$ /anotherdirectory/$1 [R=301,NC,L]

.htacess url rewrite rule to shortern the url and remove "?st_id=" from it

I currently goto:
support-requests/?st_id=7
Ideally i would like to just go straight here using .htaccess url-rewriting to make the page neater to look at and navigate to without the "?st_id=" being displayed in the url.
support-requests/7
This is what i currently have but i know its wrong and it does not work:
RewriteCond %{QUERY_STRING} ^(\w+)=(\w+)$
RewriteRule support-requests/ support-requests/%1/%2/?
Could i have some assistance in getting this correct please?
Thanks
Use this:
RewriteEngine On
RewriteRule ^support-requests/([^/]*)$ /support-requests/?st_id=$1 [L]
Should leave you with:
www.example.com/support-requests/7

Mod_Rewrite with .htaccess is not working

I just learnt about url-rewrite for my website with .htacess. My actual url is:
localhost/index.php?view=some-page
So i write this RewriteRule like this:
RewriteRule ^/([^/]*)/?$ /index.php?view=$1 [NC,L]
When i typed localhost/homepage on my browser, It does not work, it displays error 404 object not found. What have i done wrong please show me.
Many thanks
This should work in your DocumentRoot/.htaccess:
RewriteEngine On
RewriteBase /
RewriteRule ^([^/]+)/?$ index.php?view=$1 [QSA,L]
Leading slash is not matched in htaccess.
are you using apache?
This link from step 6 helped me
https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-on-ubuntu-14-04
When i was playing around with rewrites i had to enable it and tell apache where the pages were stored

htaccess RewriteRule redirecting for URL's without trailing slashes

I have this snippet in my .htaccess file to defend against anyone trying to get into the app directory.
RewriteCond %{REQUEST_URI} ^/app.*$
RewriteRule ^(.*[^/])/?$ index.php?r=$1 [L,QSA]
And although it works when I go to http://domain/app/, if I make a request to http://domain/app, it redirects to http://domain/app/?r=app.
Does anyone know what needs to be changed to stop such redirection?
Try the DirectorySlash directive that can be use globally or per directory.
http://httpd.apache.org/docs/2.2/mod/mod_dir.html#directoryslash
try using
[L]
instead of
[L,QSA]

Resources