I have a serious problem which is the next :
I have a directory like this : http://example.com/kl/bold2/bold3/contents/
what I would like to do is to make is a rewrite, for example I have :
http://example.com/kl/bold2/bold3/contents/menu.php?menu=herewego
and I would like to transfer it to this :
http://example.com/herewego
So, guys how can I do this with htaccess ?
Thank you for helping !
you should put something in url that Apache can decide which rule should apply! otherwise it's impossible to rewrite URL with correct rule!
for example :http://example.com/longdir/herewego
RewriteRule ^longdir/(.*)$ kl/bold2/bold3/contents/menu.php?menu=$1
Related
I would like to ignore all query-strings in my redirect. How would I achieve this?
Basically, /project/(.*) should always redirect to /?tag=project&id=$1
/project/100?shareid=fromsomeemailprovider
should end et the ? and only redirect to Id 100.
Thank You!
I tried the following:
^/project/([^/]*)[/]?(.*)$
/?tag=project&id=$1&$2
to put the query-string behind another &, but this only works if the first URL hast a / at the end of it, which it often hasn't and the RewriteRule can't detect the ? sadly.
With your shown samples, please try following htaccess rules file.
RewriteEngine ON
RewriteRule ^(project)/(.*)/?$ index.php?tag=$1&id=$2 [QSA,NC,L]
Please make sure:
You clear your browser cache before testing your URLs.
You make sure to keep your index.php file along with your htaccess rules file. Also add / in case both of these files are in root location in your system.
I'm a newbie in writing .htaccess file and even after 3 hours of tutorial, I still can't achieve what I want...
Hope you could help me :) ! :
FIRST I need to redirect my website http://www.runnincity.com to http://www.runnincity.world
To do so, I wrote a .htaccess file located to the root of runnincity.com with the code :
Redirect permanent / http://www.runnincity.world/
This is fine.
THEN I need http://www.runnincity.com/blog to be reachable through the URL http://www.runnincity.world/blog but I don't want the rewriting to be visible for the user. So if the user write http://www.runnincity.world/blog, the URL must stay as it is but display the content of www.runnincity.com/blog .
I wrote a new .htaccess located in the root of runnincity.world with the code below (but doesn't work) :
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^runnincity.world/blog$ runnincity.com/blog [P]
I feel completely lost ... thanks for your help !
I need help from experts to solve my problem. I'm just starting to learn rewriterule, rbase, and rcond. I want to rewrite my site link like codeigniter MVC. For example:
http://localhost/app/index.php?page=profile&user=john -> http://localhost/app/index/page/profile/user/john
How to do that? I tried to change for many times, but i don't get url like that but error occured.
RewriteRule ^index/page/(.*)/user/(.*)$ /index.php?page=$1&user=$2 [L]
I’m a noob in url rewriting and i really need help to figure this out :
I have this url : section/news.php?url=section/news/27-how_to_make_rewrite.html I want to access this news with the url parameter and the link would be : section/news/27-how_to_make_rewrite.html
the .htacess file is in the root, i have a folder named section and inside this folder i have the news folder
This doest work for me.
I have :
RewriteEngine on
RewriteBase /section/
RewriteRule news/^([a-zA-Z0-9-+/]+)/$ news/news.php?url=$1
How I can do it ?
I have not used this with subfolders, but I would try something like this.
RewriteRule ^news/([^/\.]+)/?$ news/news.php?url=section/news/$1 [L]
Edit
Try it this way:
RewriteRule ^section/news/([^/.]+)/?$ news.php?url=section/news/$1 [L]
You normally only want to put what is changing in the variable. section/news/ is always used so you should keep it outside of the replacement.
If the URI you want to rewrite to looks like: section/news.php?url=section/news/27-how_to_make_rewrite.html
then you've got one too many "news" in your target. You also need to fix your regex pattern to match stuff like 27-how_to_make_rewrite.html.
You want something like:
RewriteEngine on
RewriteBase /section/
RewriteRule news/(.+)/?$ news/news.php?url=section/news/$1
I've been trying to create a rule.
If anyone could help, I would be extremely grateful.
Request: domain.com/c/wb.php?p=rs/rs/1tb/25n/ru/rs
Rewrite to: domain.com/c/wb/rs/rs/1tb/25n/ru/rs
Thanks in Advance
I think you have this a bit backwards. The idea behind URL rewriting is that you take a nice neat URL like this (what the user sees):
http://domain.com/c/wb/rs/rs/1tb/25n/ru/rs
and rewrite it behind the scenes into an uglier but PHP etc. friendlier URL like this (what the server processes):
http://domain.com/c/wb.php?p=rs/rs/1tb/25n/ru/rs
To do that, use this:
RewriteEngine On
RewriteRule ^/c/wb/(.*) http://domain.com/c/wb.php?p=$1 [L, NS]
It should look something like this
RewriteRule ^(c/wb)\.php\?p=(rs/rs/1tb/25n/ru/rs)$ $1/$2 [L,NS]
Still I'm not sure if you need slash in front of c/wb if you're using this in your .htaccess file. You need slash if you're using this in the VirtualHost configuration.