Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
htaccess & 301 redirect
#1
Hi,

I have a question regarding the htaccess and 301 redirect.
Sorry but I’m completely new in this topic and just added the following codes from the get-simple wiki. http://get-simple.info/wiki/config:htaccess


My htaccess looks like this (my-website.de is just an example):

...
RewriteEngine on

RewriteCond %{HTTP_HOST} !^www\.my-website-test\.de$
RewriteRule ^(.*)$ http://www.my-website-test.de/$1 [L,R=301]

# Usually it RewriteBase is just '/', but
# replace it with your subdirectory path
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ([A-Za-z0-9-]+).html index.php?id=$1 [QSA,L]

Redirect 301 /landingpage1.html http://www.my-website-test.de/landingpage2.html


Unfortunately the 301 redirect looks like this

"http://www.my-website-test.de/landingpage1.html"
--> 301 redirect to
"http://www.my-website-test.de/landingpage2.html?id=landingpage1"

The website with the id ("http://www.my-website-test.de/landingpage2.html?id=landingpage1") does not work and I don’t really need the “id=” parameter.

I think the ID is added because of this part.
RewriteRule ([A-Za-z0-9-]+).html index.php?id=$1 [QSA,L]

I added this rewrite rule because I want to have websites with .html ending instead of php. (http://get-simple.info/wiki/config:htaccess)


How can I change the htaccess to redirect from
"http://www.my-website-test.de/landingpage1.html"
to
"http://www.my-website-test.de/landingpage2.html" (without ID)
Reply
#2
Your redirect is after your rewrite
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#3
Hi Shawn,

thanks for your answer.

Unfortunately it still does not work.

When I change the htaccess to:

Redirect 301 /landingpage1.html http://www.my-website-test.de/landingpage2.html

RewriteEngine on

RewriteCond %{HTTP_HOST} !^www\.my-website-test\.de$
RewriteRule ^(.*)$ http://www.my-website-test.de/$1 [L,R=301]

# Usually it RewriteBase is just '/', but
# replace it with your subdirectory path
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ([A-Za-z0-9-]+).html index.php?id=$1 [QSA,L]


I still get as Redirect URL:
"http://www.my-website-test.de/landingpage2.html?id=landingpage1"

instead of
"http://www.my-website-test.de/landingpage2.html"

Is there a possibility to get the redirect URL without "?id=..." and still use .html endings for the website urls?

Thanks a lot
Reply
#4
test with 302
301 means "moved permanently do not request again" pretty much,


Redirect 302 /test.html http://google.com
works for me

If you have a subdirectory you have to add it /sub/test.html

If you are redirectig to the same domain just remove all that nonsense
Redirect 302 /test.html /test.php
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply




Users browsing this thread: 1 Guest(s)