Zum Inhalt springen

Redirect von PHP-Links

Erstellt am 31. August 2009 · 5 Antworten · letzte Antwort am 31. August 2009

Tags: Frage

freshman17 ·

Hi,

so wie ich es verstanden habe möchtest du nur eine bestimmte URI umbiegen, oder? Also kein Ersatz zu RealUrl etc. Klar geht es z.b. mit der .htaccess bzw. mod_rewrite

RewriteEngine ON
RewriteBase /
RewriteCond %{REQUEST_URI}\?%{QUERY_STRING} /index\.php\?id=89  
RewriteRule ^ http://www.xyz.de/test.hmtl  [L,R=301]

Es gibt zahlreiche Möglichkeiten (besonders mit mod_rewrite) aber auch mit PHP jedoch per .htaccess ist es am einfachsten.

Gruß

M-Tech ·

Hi,

danke für deine Antwort.

Wie sieht denn die ganze Sache aus, wenn ich z.B. 5 URL´s umschreiben möchte?

Einfach 5x das gleiche hintereinander?

Ich bekomm einfach RealURL nicht zum laufen, so wie ich es will. Keine Ahnung wieso.

Viele Grüße

Sascha

freshman17 ·

Für "sprechende" uri würde ich dir von solchen Lösungen abraten. Wo genau ist den dein Problem mit RealUrl? Wo willst es zum laufen bekommen Server oder lokal?

Hier ein kleines Install-Tut (auf dem Server):

1. Extension Installiern
2. in RealUrl-Einstellungen
- Hacken bei "Enable automatic configuration" raus
- in "Path to configuration file [configFile]" trägst du ein:
typo3conf/realurlconf.php
3. per FTP im Verzeichnis "typo3conf" die Datei "realurlconf.php" mit folgendem Inhalt erstellen und 'rootpage_id' => xxxx an deine anpassen

<?php 
$TYPO3_CONF_VARS['EXTCONF']['realurl']['_DEFAULT'] = array(
        'init' => array(
            'enableCHashCache' => 1,
            'appendMissingSlash' => 'ifNotFile',
            'enableUrlDecodeCache' => 1,
            'enableUrlEncodeCache' => 1,
            'respectSimulateStaticURLs' => 0,
            'postVarSet_failureMode'=>'redirect_goodUpperDir',
        ),
    'redirects_regex' => array (
    
    ),
    'preVars' => array(
                        array(
                                'GETvar' => 'no_cache',
                                'valueMap' => array(
                                    'no_cache' => 1,
                                ),
                                'noMatch' => 'bypass',
                        ),
                         array(
                             'GETvar' => 'L',
                             'valueMap' => array(
                                                'en' => '1',
                                        ),
                                'noMatch' => 'bypass',
                        ),
                ),
     'pagePath' => array(
            'type' => 'user',
            'userFunc' => 'EXT:realurl/class.tx_realurl_advanced.php:&tx_realurl_advanced->main',
            'spaceCharacter' => '-',
            'languageGetVar' => 'L',
            'expireDays' => 7,
            'rootpage_id' => 1, // <= hier die id der Root-Seite eintragen
        ),


      'postVarSets' => array(
            '_DEFAULT' => array(
                // news archive parameters
                'archive' => array(
                    array(
                        'GETvar' => 'tx_ttnews[year]' ,
                        ),
                    array(
                        'GETvar' => 'tx_ttnews[month]' ,
                            'valueMap' => array(
                            'january' => '01',
                            'february' => '02',
                            'march' => '03',
                            'april' => '04',
                            'may' => '05',
                            'june' => '06',
                            'july' => '07',
                            'august' => '08',
                            'september' => '09',
                            'october' => '10',
                            'november' => '11',
                            'december' => '12',
                            )
                        ),
                    ),
                // news pagebrowser
                'browse' => array(
                    array(
                        'GETvar' => 'tx_ttnews[pointer]',
                        ),
                    ),
                // news categories
                'select_category' => array (
                    array(
                        'GETvar' => 'tx_ttnews[cat]',
                        ),
                    ),
                // news articles and searchwords
                'article' => array(
                    array(
                        'GETvar' => 'tx_ttnews[tt_news]',
                        'lookUpTable' => array(
                            'table' => 'tt_news',
                            'id_field' => 'uid',
                            'alias_field' => 'title',
                            'addWhereClause' => ' AND NOT deleted',
                            'useUniqueCache' => 1,
                            'useUniqueCache_conf' => array(
                                'strtolower' => 1,
                                'spaceCharacter' => '-',
                                ),
                            ),
                        ),
                    array(
                        'GETvar' => 'tx_ttnews[swords]',
                        ),
                    ),
                ),             
            ),

      'fileName' => array(
            'defaultToHTMLsuffixOnPrev'=>0,
            'index' => array(
                'rss.xml' => array(
                    'keyValues' => array(
                        'type' => 100,
                    ),
                ),
                'rss091.xml' => array(
                    'keyValues' => array(
                        'type' => 101,
                    ),
                ),
                'rdf.xml' => array(
                    'keyValues' => array(
                        'type' => 102,
                    ),
                ),
                'atom.xml' => array(
                    'keyValues' => array(
                        'type' => 103,
                    ),
                ),
            ),
        ),
 );
 php?>

4. Template->Setup

config {
  prefixLocalAnchors = all
  simulateStaticDocuments = 0
  baseURL = http://xyz.de/
  tx_realurl_enable = 1
}

5. im root (da wo deine URL verweist) liegt eine die _.htaccess. Hier den _ entfernen also in .htaccess umbennen und nach diesen Zeilen

### End: Miscellaneous ###

# Add your own rules here
# ...

das eintragen:

RewriteEngine On
RewriteRule ^typo3$ - [L]
RewriteRule ^typo3/.*$ - [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule .* index.php

6. Cache löschen und fertig

Alternativ kannst du auch cooluri benutzen aber realurl ist mächtiger.

M-Tech ·

Hallo Zusammen,

mein Problem mit RealURL liegt darin, daß ich keine .html-Links bekomme. Ich bekomm lediglich einen Link, z.B. www.xyz.de/test/test2/ und das wars. Das will ich nicht.

Ich hätte eben gerne, dass wenn jemand z.B. www.xyz.de/index.php?id=89 eingibt automatisch auf einer .html-Seite landet.

Das ganze Problem ist wegen der Optimierung für Goolge. Momentan habe ich im Google-Index die dynammischen Links, wie z.B. www.xyz.de/index.php?id=89 und dann auch noch die www.xyz.de/test2.html.

Momentan mache ich das alles mit simulatestaticdocument und das wars.

Grüße

Sascha

freshman17 ·

Die Endung .html kann du in der Konfigurationsdatei ("realurlconf.php" oben) von Real ab/auschalten.

'defaultToHTMLsuffixOnPrev'=>0