2017-01-18 2 views
0

Ich habe statische AMPhtml-Dateien gemacht, die ich später mit WordPress verbinden möchte.Wordpress .htaccess benutzerdefinierte HTML-Seiten umschreiben

Meine Struktur ist:

/amp/index.html

/amp/subpages.html

Ich habe jetzt soooo lange Zeit versucht, und es funktioniert nicht, wie Ich mag würde es funktioniert.

in .htaccess im Root-Verzeichnis Ich habe:

# BEGIN Static AMP 
 
RewriteEngine On 
 
RewriteRule ^index\.html$/[R,L,NC] 
 
RewriteRule ^(.*)\.html$ /$1 [R,L] 
 
# END Static AMP 
 

 
# BEGIN Security 
 
<files wp-config.php> 
 
    order allow,deny 
 
    deny from all 
 
</files> 
 
Options -Indexes 
 
<files ~ "^.*\.([Hh][Tt][Aa])"> 
 
    order allow,deny 
 
    deny from all 
 
    satisfy all 
 
</files> 
 
# END Security 
 

 
# 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 
 

 
#-----------------------------------------------------------------# 
 
# NOTE:               # 
 
# When testing your .htaccess do not use 301 redirects.   # 
 
# Use 302 until finished testing, as the browser will cache 301s. # 
 
#-----------------------------------------------------------------# 
 

 
#-----------------------------------------------------------------------------# 
 
# FLAGS:                  # 
 
# [R] redirect, by default 302, can use [R=301]        # 
 
# [NC] flag causes the RewriteRule to be matched in a case-insensitive manner # 
 
# [L] flag causes mod_rewrite to stop processing the rule set.    # 
 
#-----------------------------------------------------------------------------#

Was würde ich dies gerne tun

Umschreiben

http://www.example.com/amp/index.html zu http://www.example.com/amp/

und

http://www.example.com/amp/subpages.html zu http://www.example.com/amp/subpages

Irgendwelche Vorschläge?

Antwort

0

Beantworten meiner eigenen Frage.

# BEGIN Static AMP 
 
\t <IfModule mod_rewrite.c> 
 
\t \t RewriteEngine On 
 
\t \t RewriteRule ^amp/index\.html$ /amp [R,L,NC] 
 
\t \t # example.com/page will display the contents of example.com/page.html 
 
\t \t RewriteCond %{REQUEST_FILENAME} !-f 
 
\t \t RewriteCond %{REQUEST_FILENAME} !-d 
 
\t \t RewriteCond %{REQUEST_FILENAME}.html -f 
 
\t \t RewriteRule ^(.+)$ $1.html [L,QSA] 
 
\t \t # 301 from example.com/page.html to example.com/page 
 
\t \t RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*\.html\ HTTP/ 
 
\t \t RewriteRule ^(.*)\.html$ /$1 [R=301] 
 
\t \t RewriteRule ^amp/index$ /amp [R=301,L] 
 
\t </IfModule> 
 
# END Static AMP 
 

 
# BEGIN Security 
 
<files wp-config.php> 
 
    order allow,deny 
 
    deny from all 
 
</files> 
 
Options -Indexes 
 
<files ~ "^.*\.([Hh][Tt][Aa])"> 
 
    order allow,deny 
 
    deny from all 
 
    satisfy all 
 
</files> 
 
# END Security 
 

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

 
#-----------------------------------------------------------------# 
 
# NOTE:               # 
 
# When testing your .htaccess do not use 301 redirects.   # 
 
# Use 302 until finished testing, as the browser will cache 301s. # 
 
#-----------------------------------------------------------------# 
 

 
#-----------------------------------------------------------------------------# 
 
# FLAGS:                  # 
 
# [R] redirect, by default 302, can use [R=301]        # 
 
# [NC] flag causes the RewriteRule to be matched in a case-insensitive manner # 
 
# [L] flag causes mod_rewrite to stop processing the rule set.    # 
 
#-----------------------------------------------------------------------------# 
 

 
#-------------------------------------------------------# 
 
# This checks for existing folders (-d) and files (-f): # 
 
# RewriteCond %{REQUEST_FILENAME} !-d     # 
 
# RewriteCond %{REQUEST_FILENAME} !-f     # 
 
#-------------------------------------------------------# 
 

 
#-------------------------# 
 
# .HTACCESS Testing Tool # 
 
# http://htaccess.mwl.be/ # 
 
#-------------------------#