Htaccess Frage Mod rewrite

Fragen zu allen Themen rund ums Programmieren außerhalb von phpBB können hier gestellt werden - auch zu anderen Programmiersprachen oder Software wie Webservern und Editoren.
Antworten
Lizardx
Mitglied
Beiträge: 212
Registriert: 20.05.2006 18:35

Htaccess Frage Mod rewrite

Beitrag von Lizardx »

Hallo,

ich habe noch eine alte phpBB Version online, mit SEO Urls. Leider wurde ja der Support von phpBB SEO eingestellt und nun habe ich ein großes Problem:

Ich würde gerne auf die aktuelle Version updaten ohne irgendwelche Mods. Das stelle ich mir nun sehr schwierig vor, da die Url Struktur anders ist. Aktuell lauten die Urls in meinem Forum in etwa so:

forum1.html
topic7679.html
topic7679-15.html

Ich würde jetzt gerne auf die neue Version updaten, aber die alten Urls sollen auf die neuen Urls umgeleitet werden. Es gibt im Forum sehr viele interne Links innerhalb der Beiträge. Damit nach dem Update kein Chaos entsteht, wäre es sehr wichtig, dass die internen Links zu den richtigen Seiten führen. Wie stelle ich das an?

Hier ein Auszug aus meiner aktuellen htacess Datei:

Code: Alles auswählen

RewriteBase /
# HERE IS A GOOD PLACE TO FORCE CANONICAL DOMAIN
# RewriteCond %{HTTP_HOST} !^forum\.domain\.com$ [NC]
# RewriteRule ^(.*)$ http://forum.domain.com/$1 [QSA,L,R=301]

# DO NOT GO FURTHER IF THE REQUESTED FILE / DIR DOES EXISTS
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule . - [L]
#####################################################
# PHPBB SEO REWRITE RULES ALL MODES
#####################################################
# AUTHOR : dcz www.phpbb-seo.com
# STARTED : 01/2006
#################################
# FORUMS PAGES
###############
# FORUM INDEX REWRITERULE WOULD STAND HERE IF USED. "forum" REQUIRES TO BE SET AS FORUM INDEX
# RewriteRule ^forum\.html$ /index.php [QSA,L,NC]
# FORUM ALL MODES
RewriteRule ^(forum|[a-z0-9_-]*-f)([0-9]+)(-([0-9]+))?\.html$ /viewforum.php?f=$2&start=$4 [QSA,L,NC]
# TOPIC WITH VIRTUAL FOLDER ALL MODES
RewriteRule ^(forum|[a-z0-9_-]*-f)([0-9]+)/(topic|[a-z0-9_-]*-t)([0-9]+)(-([0-9]+))?\.html$ /viewtopic.php?f=$2&t=$4&start=$6 [QSA,L,NC]
# TOPIC WITHOUT FORUM ID & DELIM ALL MODES
RewriteRule ^([a-z0-9_-]*)/?(topic|[a-z0-9_-]*-t)([0-9]+)(-([0-9]+))?\.html$ /viewtopic.php?forum_uri=$1&t=$3&start=$5 [QSA,L,NC]
# PHPBB FILES ALL MODES
RewriteRule ^resources/[a-z0-9_-]+/(thumb/)?([0-9]+)$ /download/file.php?id=$2&t=$1 [QSA,L,NC]
# PROFILES ALL MODES WITH ID
RewriteRule ^(member|[a-z0-9_-]*-u)([0-9]+)/?$ /memberlist.php?mode=viewprofile&u=$2 [QSA,L,NC]
# USER MESSAGES ALL MODES WITH ID
RewriteRule ^(member|[a-z0-9_-]*-u)([0-9]+)/(topics|posts)/?(page([0-9]+)\.html)?$ /search.php?author_id=$2&sr=$3&start=$5 [QSA,L,NC]
# GROUPS ALL MODES
RewriteRule ^(group|[a-z0-9_-]*-g)([0-9]+)(-([0-9]+))?\.html$ /memberlist.php?mode=group&g=$2&start=$4 [QSA,L,NC]
# POST
RewriteRule ^post([0-9]+)\.html$ /viewtopic.php?p=$1 [QSA,L,NC]
# ACTIVE TOPICS
RewriteRule ^active-topics(-([0-9]+))?\.html$ /search.php?search_id=active_topics&start=$2&sr=topics [QSA,L,NC]
# UNANSWERED TOPICS
RewriteRule ^unanswered(-([0-9]+))?\.html$ /search.php?search_id=unanswered&start=$2&sr=topics [QSA,L,NC]
# NEW POSTS
RewriteRule ^newposts(-([0-9]+))?\.html$ /search.php?search_id=newposts&start=$2&sr=topics [QSA,L,NC]
# UNREAD POSTS
RewriteRule ^unreadposts(-([0-9]+))?\.html$ /search.php?search_id=unreadposts&start=$2 [QSA,L,NC]
# THE TEAM
RewriteRule ^the-team\.html$ /memberlist.php?mode=leaders [QSA,L,NC]
# HERE IS A GOOD PLACE TO ADD OTHER PHPBB RELATED REWRITERULES

#####################################################
# GYM Sitemaps & RSS
# Global channels
RewriteRule ^rss(/(news)+)?(/(digest)+)?(/(short|long)+)?/?$ /gymrss.php?channels&$2&$4&$6 [QSA,L,NC]
# HTML Global news & maps
RewriteRule ^(news|maps)/?(page([0-9]+)\.html)?$ /map.php?$1&start=$3 [QSA,L,NC]
# END GYM Sitemaps & RSS
#####################################################

# FORUM WITHOUT ID & DELIM ALL MODES
# THESE FOUR LINES MUST BE LOCATED AT THE END OF YOUR HTACCESS TO WORK PROPERLY
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([a-z0-9_-]+)(-([0-9]+))\.html$ /viewforum.php?forum_uri=$1&start=$3 [QSA,L,NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([a-z0-9_-]+)\.html$ /viewforum.php?forum_uri=$1 [QSA,L,NC]
# FIX RELATIVE PATHS : FILES
RewriteRule ^.+/(style\.php|ucp\.php|mcp\.php|faq\.php|download/file.php)$ /$1 [QSA,L,NC,R=301]
# FIX RELATIVE PATHS : IMAGES
RewriteRule ^.+/(styles/.*|images/.*)/$ /$1 [QSA,L,NC,R=301]
# END PHPBB PAGES

Meine Frage nun: Ist es möglich, die htaccess so umzuändern, dass die alten Urls auf die neuen Urls umgeleitet werden?

Gruß
Benutzeravatar
tas2580
Ehemaliges Teammitglied
Beiträge: 3029
Registriert: 01.07.2004 05:42
Wohnort: /home/tas2580
Kontaktdaten:

Re: Htaccess Frage Mod rewrite

Beitrag von tas2580 »

Hallo,

ändere alle [QSA,L,NC] in [QSA,L,NC,R=301] dann sollten die SEO URLs per 301 auf die ursprünglichen URLs umleiten.

Gruß Tobi
Heute ist ein guter Tag um dein Forum zu testen.
Ehemaliger Benutzername: [BTK] Tobi
Lizardx
Mitglied
Beiträge: 212
Registriert: 20.05.2006 18:35

Re: Htaccess Frage Mod rewrite

Beitrag von Lizardx »

Cool, das hört sich ja recht unkompliziert an. Ich werde es versuchen. Danke schonmal!
Lizardx
Mitglied
Beiträge: 212
Registriert: 20.05.2006 18:35

Re: Htaccess Frage Mod rewrite

Beitrag von Lizardx »

Das hat leider nicht geklappt. Ich sehe keinerlei Änderungen. Ich habe die htaccess entsprechend angepasst und den Cache geleert.
Hier mein aktueller Code:

Code: Alles auswählen

AddHandler af_php56 .php


<IfModule mod_rewrite.c>
RewriteEngine on

#
# Uncomment the statement below if URL rewriting doesn't
# work properly. If you installed phpBB in a subdirectory
# of your site, properly set the argument for the statement.
# e.g.: if your domain is test.com and you installed phpBB
# in http://www.test.com/phpBB/index.php you have to set
# the statement RewriteBase /phpBB/
#
#RewriteBase /

#
# Uncomment the statement below if you want to make use of
# HTTP authentication and it does not already work.
# This could be required if you are for example using PHP via Apache CGI.
#
#RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]

#
# The following 3 lines will rewrite URLs passed through the front controller
# to not require app.php in the actual URL. In other words, a controller is
# by default accessed at /app.php/my/controller, but can also be accessed at
# /my/controller
#
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ app.php [QSA,L]

#
# If symbolic links are not already being followed,
# uncomment the line below.
# http://anothersysadmin.wordpress.com/2008/06/10/mod_rewrite-forbidden-403-with-apache-228/
#
#Options +FollowSymLinks
</IfModule>


<IfModule mod_version.c>
	<IfVersion < 2.4>
		<Files "config.php">
			Order Allow,Deny
			Deny from All
		</Files>
		<Files "common.php">
			Order Allow,Deny
			Deny from All
		</Files>
	</IfVersion>
	<IfVersion >= 2.4>
		<Files "config.php">
			Require all denied
		</Files>
		<Files "common.php">
			Require all denied
		</Files>
	</IfVersion>
</IfModule>
<IfModule !mod_version.c>
	<IfModule !mod_authz_core.c>
		<Files "config.php">
			Order Allow,Deny
			Deny from All
		</Files>
		<Files "common.php">
			Order Allow,Deny
			Deny from All
		</Files>
	</IfModule>
	<IfModule mod_authz_core.c>
		<Files "config.php">
			Require all denied
		</Files>
		<Files "common.php">
			Require all denied
		</Files>
	</IfModule>
</IfModule>














RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule . - [L]

# FORUM INDEX REWRITERULE WOULD STAND HERE IF USED. "forum" REQUIRES TO BE SET AS FORUM INDEX
# RewriteRule ^forum\.html$ index.php [QSA,L,NC,R=301]
# FORUM ALL MODES
RewriteRule ^(forum|[a-z0-9_-]*-f)([0-9]+)(-([0-9]+))?\.html$ viewforum.php?f=$2&start=$4 [QSA,L,NC,R=301]
# TOPIC WITH VIRTUAL FOLDER ALL MODES
RewriteRule ^(forum|[a-z0-9_-]*-f)([0-9]+)/(topic|[a-z0-9_-]*-t)([0-9]+)(-([0-9]+))?\.html$ viewtopic.php?f=$2&t=$4&start=$6 [QSA,L,NC,R=301]
# TOPIC WITHOUT FORUM ID & DELIM ALL MODES
RewriteRule ^([a-z0-9_-]*)/?(topic|[a-z0-9_-]*-t)([0-9]+)(-([0-9]+))?\.html$ viewtopic.php?forum_uri=$1&t=$3&start=$5 [QSA,L,NC,R=301]
# PHPBB FILES ALL MODES
RewriteRule ^resources/[a-z0-9_-]+/(thumb/)?([0-9]+)$ download/file.php?id=$2&t=$1 [QSA,L,NC,R=301]
# PROFILES ALL MODES WITH ID
RewriteRule ^(member|[a-z0-9_-]*-u)([0-9]+)\.html$ memberlist.php?mode=viewprofile&u=$2 [QSA,L,NC,R=301]
# USER MESSAGES ALL MODES WITH ID
RewriteRule ^(member|[a-z0-9_-]*-u)([0-9]+)-(topics|posts)(-([0-9]+))?\.html$ search.php?author_id=$2&sr=$3&start=$5 [QSA,L,NC,R=301]
# GROUPS ALL MODES
RewriteRule ^(group|[a-z0-9_-]*-g)([0-9]+)(-([0-9]+))?\.html$ memberlist.php?mode=group&g=$2&start=$4 [QSA,L,NC,R=301]
# POST
RewriteRule ^post([0-9]+)\.html$ viewtopic.php?p=$1 [QSA,L,NC,R=301]
# ACTIVE TOPICS
RewriteRule ^active-topics(-([0-9]+))?\.html$ search.php?search_id=active_topics&start=$2&sr=topics [QSA,L,NC,R=301]
# UNANSWERED TOPICS
RewriteRule ^unanswered(-([0-9]+))?\.html$ search.php?search_id=unanswered&start=$2&sr=topics [QSA,L,NC,R=301]
# NEW POSTS
RewriteRule ^newposts(-([0-9]+))?\.html$ search.php?search_id=newposts&start=$2&sr=topics [QSA,L,NC,R=301]
# UNREAD POSTS
RewriteRule ^unreadposts(-([0-9]+))?\.html$ search.php?search_id=unreadposts&start=$2 [QSA,L,NC,R=301]
# THE TEAM
RewriteRule ^the-team\.html$ memberlist.php?mode=leaders [QSA,L,NC,R=301]
# HERE IS A GOOD PLACE TO ADD OTHER PHPBB RELATED REWRITERULES

#####################################################
# GYM Sitemaps & RSS
# Global channels
RewriteRule ^rss(/(news)+)?(/(digest)+)?(/(short|long)+)?/?$ gymrss.php?channels&$2&$4&$6 [QSA,L,NC,R=301]
# HTML Global news & maps
RewriteRule ^(news|maps)/?(page([0-9]+)\.html)?$ map.php?$1&start=$3 [QSA,L,NC,R=301]
# END GYM Sitemaps & RSS
#####################################################

# FORUM WITHOUT ID & DELIM ALL MODES
# THESE FOUR LINES MUST BE LOCATED AT THE END OF YOUR HTACCESS TO WORK PROPERLY
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([a-z0-9_-]+)(-([0-9]+))\.html$ viewforum.php?forum_uri=$1&start=$3 [QSA,L,NC,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([a-z0-9_-]+)\.html$ viewforum.php?forum_uri=$1 [QSA,L,NC,R=301]
# FIX RELATIVE PATHS : FILES
RewriteRule ^.+/(style\.php|ucp\.php|mcp\.php|faq\.php|download/file.php)$ $1 [QSA,L,NC,R=301]
# FIX RELATIVE PATHS : IMAGES
RewriteRule ^.+/(styles/.*|images/.*)/$ $1 [QSA,L,NC,R=301]
# END PHPBB PAGES
#####################################################

Sollte das so sein?
Antworten

Zurück zu „Coding & Technik“