开发者

Creating a redirect in htaccess for incoming requests

开发者 https://www.devze.com 2023-03-19 12:44 出处:网络
how can i redirect all requests coming on foo.bar.com/some-thing to be redirected to foo.bar.com/some-thing-else

how can i redirect all requests coming on

foo.bar.com/some-thing

to be redirected to

foo.bar.com/some-thing-else

also can you please hook me up to some good learning resources for learning htaccess, i开发者_如何学Python am very new to this development stuff.

Regards.

Edit following is the code i have been trying with (without success)

RewriteRule ^some-thing?$  index.php/some-thing-else [QSA,L] 


try something like this : in the .htaccess put this :

RewriteEngine on

# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# otherwise forward it to index.php

RewriteRule ^(.*)-thing?$  index.php?route=$1-thing-else [QSA,L]

in the index php put this for testing :

<?php echo var_dump( $_GET ); ?>

browse to your site ie http://localhost/some-thing or http://localhost/dirty-thing.

hope you can modify this to your exact needs.


It is mod_rewrite Apache module what you should be working with to do such redirects. It's not simple to learn, still very powerful tool. There are multiple tutorials learning it. Try http://www.easymodrewrite.com/ for beginning.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号