1

How would I modify my .htaccess to send http://rpgs.biz/rpg-test to just http://rpgs.biz/test

Here's my current .htaccess

Options +FollowSymLinks RewriteEngine On RewriteBase / rewriterule ^rpg-([^&]+)$ index.php?name=$1 [L] 

I greatly appreciate any help, thanks!

1

3 Answers 3

1

If your current htaccess is taking rpg-(something) and passing the "something" into index.php, you'll need to change that as well. Maybe something like:

Options +FollowSymLinks RewriteEngine On RewriteBase / RewriteRule ^rpg-([^/]+)$ /$1 [L,R=301] # this is your old rule, modified RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([^/]+)$ index.php?name=$1 [L] 
Sign up to request clarification or add additional context in comments.

4 Comments

This is exactly what I needed, thanks! Any ideas how to take this a step forward and create a subdomain instead? for example "rpgs.biz/test to test.rpgs.biz"
@SativaDiva if you are mapping everything to index.php?name= then you don't need to deal with any /test path. Match against the %{HTTP_HOST} and use %1 to backreference the match
I feel like I'm starting to get the hang of it but the last sentence confused me, could you edit the code above with an example of what that would look like? I really appreciate the help so far, you've really made my week! :)
Try doing a search for "htaccess subdomain"
0

This should work:

Redirect 301 /rpg-test http://rpgs.biz/test 

But if you need to retain the files after /rpg-test, such as /rpg-test/cart.php or something, then you'd do:

RewriteRule ^rpg-test/?(.*) http://rpgs.biz/test/$1 [R=301,L] 

Comments

0

If you want a simple redirect, it's easy:

Options +FollowSymLinks RewriteEngine On RewriteBase / RewriteRule ^rpg-([^&]+)$ /$1 [L,R=301] 

3 Comments

Sidebar: If it's a live site, you should always add the 301 in there so that you don't lose any search engine page ranking.
Very close, but let's say rpg-"test" is generated from ^rpg-([^&]+)$, simply removing rpg- so it's just ^([^&]+)$ didn't work.
@SativaDiva In this case, you need to change your RewriteRule, so you are redirected from rpg-(whatever) to /whatever. See the update.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.