Tell me more ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

htaccess redirect (301) all my old content from my wordpress to my new url-design. I want to redirect all the last trailingslashs to .html ... the permalinks are allready working, but i dont want to loose all my hardly collected backlinks. Thats how my Urls look like:

Pages (old): domain.com/pages/redirection/ should redirect to domain.com/pages/redirection.html Posts (old): domain.com/new-permalink/ shuold redirect to domain.com/news/new-permalink.html Custom Posts domain.com/permalink/ should redirect to domain.com/projects/permalink.html

Any help would be grateful :)

thx

---Comments only allow few words so i edit my question:

    <IfModule mod_rewrite.c> 
RewriteEngine On 
Options +FollowSymLinks 
RewriteBase /project/ 
RewriteRule ^index\.php$ - [L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . /project/index.php [L] 
RewriteRule /project/([^/]*)/?$ /project/$1.html [L] 

AddOutputFilterByType DEFLATE text/html text/plain text/xml application/xml application/xhtml+xml text/javascript text/css application/x-javascript BrowserMatch ^Mozilla/4 gzip-only-text/html BrowserMatch ^Mozilla/4.0[678] no-gzip BrowserMatch bMSIE !no-gzip !gzip-only-text/html </IfModule> # END WordPress

Did not work for me.. it ignores my rewritebase, so it redirects domain.com/projects/permalink/ to domain.com/permalink.html not to domain.com/projects/permalink.html

share|improve this question
If you are in /projects/ folder already, then remove /project/ from rewrite pattern for last rule; should be RewriteRule ([^/]*)/?$ /project/$1.html [L]. P.S. and please stop using xxxxx for everything -- be creative and use a bit more realistic/easy to distinguish URLs... – LazyOne Jul 26 '11 at 20:42
Ok, next time i try beeing more creative ;) ...now it returns on domain.com/project/ ...You don't have permission to access /project/.html on this server. – Gecko453 Jul 26 '11 at 21:34
Which URL you were accessing? if example.com/project/ .. then you may have such response. If so -- add RewriteRule ^$ /project/index.php [L] line after RewriteBase line, for example (but definitely before the previously mentioned rule). – LazyOne Jul 26 '11 at 21:38
doesnt work for me.. now it looks like this <IfModule mod_rewrite.c> RewriteEngine On Options +FollowSymLinks RewriteBase /project/ RewriteRule ^$ /project/index.php [L] RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /project/index.php [L] RewriteRule ([^/]*)/?$ /project/$1.html [L] </IfModule> # END WordPress – Gecko453 Jul 26 '11 at 21:52
TBH Now I'm lost on what is working, what is not (and why) and how it supposed to work. Without knowing you project details I will constrain myself from making more "wild" guesses. I can only recommend enabling rewrite debugging (if you can edit server/virtual host config) -- RewriteLogLevel 9 and check rewrite log for details. You are the person who knows for sure how site works/should work, and should see from logs what is going wrong and where. All my advices, while technically be correct, still may be inappropriate for particular situation/location. – LazyOne Jul 26 '11 at 23:40

1 Answer

RewriteRule ^pages/([^/]*)/?$ pages/$1.html

Should do the trick.

share|improve this answer
thx, but plz see my editted question :) – Gecko453 Jul 26 '11 at 20:32

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.