Everyone!
I have url like: https://example.com/web/web/publications/11233123-21331-233256667
How make this url: http://backend.example.com/web/web/publications/11233123-21331-233256667
Thanks. Sorry I am relatively new to .htaccess.
A simple .htaccess would look something like this:
RewriteEngine On
RewriteRule ^ http://backend.example.com%{REQUEST_URI}
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]
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.
I want to rewrite an url from example.php?id=123 to example-123-hello-world
(where "hello-world" is some fake text)
I tried this:
RewriteRule ^example-(.*)-(.*)$ /example.php?id=$1
it works only if there are no "-" in hello world:
example-123-helloworld
Any ideas how to do this? thanks a lot! :)
here's what you need to use:
RewriteEngine On
RewriteBase /
RewriteRule ^example\-([0-9]+)\-(.*)/?$ example.php?id=$1 [NC,QSA,L]
Try this:
RewriteRule ^example-(.*?)-(.*)$ /example.php?id=$1