I have this url:
http://dev.example.com//zina/Artist%20One%20Demo?l=7&img=artist%20pic%20can%20can%20be%20named%20anything.jpg&it=full
And it's being rewritten to this:
http://dev.example.com/?p=Artist%20One%20Demo&option=com_zina&Itemid=82&l=7&img=artist%2520pic%2520can%2520can%2520be%2520named%2520anything.jpg&it=full
Because of this rewrite rule:
RewriteRule ^zina/(.*)$ /?p=$1&option=com_zina&Itemid=82 [L,R,QSA]
Does anyone know why, and how I can correct it?
Try the NE flag:
RewriteRule ^zina/(.*)$ /?p=$1&option=com_zina&Itemid=82 [L,R,QSA,NE]
Related
I want to replace this URL:
mydomain.com/posts/1659-artigos/etc-to
By this one:
mydomain.com/etc-to
Using .htaccess I'm trying the following:
RewriteEngine on
RewriteRule ^posts/1659-artigos/(.*)$ $1
But it isn't working. No redirect happens.
Can anyone help?
Thanks!
Converting my comment to answer so that solution is easy to find for future visitors.
You can use this code to get redirect working:
RewriteEngine on
RewriteRule ^posts/1659-artigos/(.*)$ /$1 [L,R=301,NC]
You need to use / before $1 for external redirect and make sure to use R flag for full redirect.
I need the regular expression to redirect a link like this:
www.mysite.com/forums/users/tom
To: http://www.mysite.com/dashboard/listings/tom
The problem is that the script I am using constructs links like this:
www.mysite.com/forums/users/tom/favorites/
And I need to redirect ONLY the www.mysite.com/forums/users/tom and NOT the www.mysite.com/forums/users/tom/favorites/ which I would like to leave as it is.
Is there any way to do this?
Please help me. :(
This should work and only redirect mysite.com/referrer/ and not mysite.com/referrer/topic:
RewriteEngine on
RewriteRule ^referrer/$ http://someurl.com [L,R=301]
EDIT:
RewriteEngine on
RewriteRule ^forums/users/(.*)/?$ http://www.mysite.com/dashboard/listings/$1 [L,R=301]
Struggling with a rewrite rule, think it is probably just a bit of incorrect syntax.
I have a URL like this:
http://mydomain.org/foo-bar/from2012-10-29/to2012-11-02/page2/
.htaccess is located within foo-bar/
My rules:
# if uri contains dates and page:
RewriteCond %{REQUEST_URI} "from.*to.*page" [NC]
RewriteRule ^from((19|20|21)\d\d-(0[0-9]|1[012])-(0[1-9]|[12][0-9]|3[01]))/to((19|20|21)\d\d-(0[0-9]|1[012])-(0[1-9]|[12][0-9]|3[01]))/page([0-9]+)/?$ index.php?from=$1&to=$2&p=$3 [NC,L]
As you can (hopefully) see, I am trying to translate this:
http://mydomain.org/foo-bar/from2012-10-29/to2012-11-02/page2/
into this:
http://mydomain.org/foo-bar/index.php?$from=2012-10-29&$to=2012-11-02&$p=2
But the variable values I am getting are not as I expect. I am getting the following values
p= 10
from= 2012-10-29
to= 20
Hope someone can point out the obvious for me.
Thanks in advance.
Simplify your regex.
Try this code:
RewriteRule ^from([^/]+)/to([^/]+)/page([0-9]+)/?$ index.php?from=$1&to=$2&p=$3 [NC,L,QSA]
I searched in the web to find a valid solution for my problem, but nothing works.
Hopefully you guys can help me.
I want to Rewrite a URL on an Apache doing like that:
(1.) www.example.com/en/rainbow.html => www.example.com/index.php?site=rainbow&lang=en
or
(2.) www.example.com/rainbow.html =>www.example.com/index.php?site=rainbow&lang=
or
(3.) www.example.com//rainbow.html =>www.example.com/index.php?site=rainbow&lang=
To be honest, my understanding for regex isn't that good.
Tried:
RewriteEngine On
RewriteRule ^(.+)[/](.+).html|(.+).html$ index.php/?lang=$1&site=$2 [QSA]
Result: No Error, but "site" has only a param at (1.).
RewriteEngine On
RewriteRule ^(.*[/]){0,1}(.*).html$ index.php/?lang=$1&site=$2 [QSA]
Result: Works fine, but i.e. lang="en/", should be lang="en"
In which way I can improve it and let it work correct?!
Thanks a lot!!
Try this:
RewriteEngine On
RewriteRule (/en/)?([^/]+)\.html$ index.php/?site=$2lang=$1 [QSA]
No need to escape forward slashes in mod-rewrite, by the way. But you do need to escape the ., which, as you know, stands in as a wildcard in regular expressions.
I'm not an expert in url rewriting, but i like koalas:
RewriteRule /+(([^/]+)/)?([^/]+)\.html$ /index.php/?site=$3&lang=$2 [QSA]
I have the following url:
http://www.mysite.com/blog.php
and I want it to rewrite to:
http://www.mysite.com/index.php?goto=blog
How to do this in Apache2?
I've seen many examples of doing it the other way around...
Many thanks in advance,
If you want to rewrite all .php to index, you should do:
RewriteRule ^(.*).php$ index.php?goto=$1 [L,QSA]
if you would like to rewrite only some files:
RewriteRule ^(blog.php|other_file.php)/(.*)?$ index.php?goto=$1/$2 [L,QSA]
Try this (untested):
^/(.*)\.php$ /index.php?goto=$1
This should work even with other pages, not only with the blog.php.
Have a look at the documentation.