2016-05-03 15 views
0

Problem zu ändern:Rewrite und Urls Redirect die Ordnernamen aus der Urls

https://mydomain/folder1/xyz/product1 

zu

https://mydomain/xyz/product1 

Denken Sie daran, folder1 ist nicht vorhanden. Ich möchte es nur extern umschreiben und intern sollte es auf alte Links verweisen. Zum Beispiel

wenn Benutzer klickt: https://mydomain/folder1/xyz/product1 der Benutzer zeigt automatisch einen Link https://mydomain/xyz/product1 in Browser aber der Inhalt noch von https://mydomain/folder1/xyz/product1

Lösungen versuchte RewriteEngine On RewriteBase/

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+(folder)\ [NC] 
RewriteRule^/%1/? [R=302,L] 

RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{DOCUMENT_ROOT}/$1\-f 
RewriteRule ^(.+?)/$ $1.php [L] 

.htaccess kommen sollte Datei

RewriteOptions inherit 
 

 
# BEGIN WordPress 
 
<IfModule mod_rewrite.c> 
 
RewriteEngine On 
 
RewriteBase/
 
RewriteRule ^index\.php$ - [L] 
 
RewriteCond %{REQUEST_FILENAME} !-f 
 
RewriteCond %{REQUEST_FILENAME} !-d 
 
RewriteRule . /index.php [L] 
 
</IfModule> 
 

 
# END WordPress 
 

 

 
<IfModule mod_rewrite.c> 
 
RewriteEngine on 
 

 
RewriteBase/
 
RewriteRule ^best-price/(.+)$ /$1 [L] 
 
RewriteCond %{REQUEST_FILENAME} !-d 
 
RewriteCond %{DOCUMENT_ROOT}/$1.php -f 
 
RewriteRule ^(.+?)/?$ $1.php [L] 
 
</IfModule> 
 

 

 

 
# Header unset Pragma 
 
# FileETag None 
 
# Header unset ETag 
 
## EXPIRES CACHING ## 
 
<IfModule mod_expires.c> 
 
ExpiresActive On 
 
ExpiresByType image/jpg "access 1 year" 
 
ExpiresByType image/jpeg "access 1 year" 
 
ExpiresByType image/gif "access 1 year" 
 
ExpiresByType image/png "access 1 year" 
 
ExpiresByType text/css "access 1 month" 
 
ExpiresByType text/html "access 1 month" 
 
ExpiresByType application/pdf "access 1 month" 
 
ExpiresByType text/x-javascript "access 1 month" 
 
ExpiresByType application/x-shockwave-flash "access 1 month" 
 
ExpiresByType image/x-icon "access 1 year" 
 
ExpiresDefault "access 1 month" 
 
</IfModule> 
 
## EXPIRES CACHING ## 
 
<IfModule mod_gzip.c> 
 
mod_gzip_on Yes 
 
mod_gzip_dechunk Yes 
 
mod_gzip_item_include file \.(html?|txt|css|js|php|pl)$ 
 
mod_gzip_item_include handler ^cgi-script$ 
 
mod_gzip_item_include mime ^text/.* 
 
mod_gzip_item_include mime ^application/x-javascript.* 
 
mod_gzip_item_exclude mime ^image/.* 
 
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.* 
 
</IfModule> 
 
# Disable server signature 
 
ServerSignature Off

Antwort

1

Neuschreiben/folder1/xyz/xyz versuchen die folgende Regel:

RewriteEngine on 

RewriteRule ^folder1/(.+)$ /$1 [L] 

.htaccess:

RewriteEngine on 

RewriteBase/
RewriteRule ^folder1/(.+)$ /$1 [L,R] 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{DOCUMENT_ROOT}/$1.php -f 
RewriteRule ^(.+?)/?$ $1.php [L] 
+0

warum diese php in der 5. und 6. Zeile –

+0

@AnkitJain leid , Was meinen Sie? – starkeen

+0

'RewriteRule^(. +?)/$ $ 1.php [L]' Ich habe die Bedeutung dieser Zeile nicht verstanden. Warum verwenden Sie '.php' darin. Meine Urls enthält nicht 'php' –