Reputation: 2715
I am really stuck with my .htaccess file, and need some help :). I have a WordPress installation that I am using for testing. It is in a folder and I use .htaccess to get there. This is the rules I use so far:
######### Custom #########
RewriteEngine On
# ignore folders
RewriteCond %{REQUEST_URI} "/af1wp/"
RewriteRule (.*) $1 [L]
###############
# only for me #
###############
# HOME (Senne Tijdeman)
RewriteCond %{REMOTE_ADDR} ^###\.###\.###\.###$
RewriteCond %{HTTP_HOST} ^((www.)?([a-z0-9_\-]+).)?alleenf1.nl$
RewriteCond %{REQUEST_URI} !^/af1wp/$
RewriteRule ^(.*)$ /af1wp/$1 [L]
This works (with my real IP address of course), so no problem there. But now I want to rewrite exisiting URL's to a new format. The old URL is this:
http://alleenf1.nl/nieuws/QOgbb/raikkonen-alles-is-mogelijk-in-australi
The new URL should be this:
http://alleenf1.nl/raikkonen-alles-is-mogelijk-in-australi
The part I want to remove "nieuws/QOgbb/" is not always the same, so I have to use regex for that. But everything I tried did not work at all.
I thought this would be simple, but apparently not for me unfortunately. Now I have 2 questions.
Tnx in advanced
To awnser the questions from poncha below:
/raikkonen-alles-is-mogelijk-in-australi
is a post in WordPress. That WordPress installation currently resides in the folder af1wp, but will be moved to the root folder when going live.Upvotes: 0
Views: 139
Reputation: 7866
Try this:
RewriteEngine On
RewriteRule ^nieuws/([^/]+)/(.*) /af1wp/$1 [R=301,L,QSA]
/af1wp/
, change it to /
when moving the wordpress.R=301
- redirect with HTTP status 301 (Moved Permanently).L
- last rule (stop rules parsing after successful match of this rule)QSA
- query-string-append (append original query string to the rewritten request).Upvotes: 1