• I’ve just installed wordpress on the server and created a couple of pages. I want to change the old site (which was once a static site and is currently redirecting to .html extensions) to a new wordpress one with permalink structure /%postname%/ . I can’t figure out how to modify the .htaccess file to redirect a typed .html link to a trailing slash/ . Nothing seems to work. My .htaccess file is as follows

    #added bits
    
    # BEGIN WordPress
    
    <IfModule mod_rewrite.c>
    ErrorDocument 404 /index.php?error=404
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    
    # END WordPress
    # END added bits
    
    # 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
    
    # BEGIN wtwp_cache
    <IfModule mod_mime.c>
    
    	# Text
    	AddType text/css .css
    	AddType application/x-javascript .js
    	AddType text/html .html .htm
    	AddType text/richtext .rtf .rtx
    	AddType text/plain .txt
    	AddType text/xml .xml
    
    	# Image
    	AddType image/gif .gif
    	AddType image/x-icon .ico
    	AddType image/jpeg .jpg .jpeg .jpe
    	AddType image/png .png
    	AddType image/svg+xml .svg .svgz
    
    	# Video
    	AddType video/asf .asf .asx .wax .wmv .wmx
    	AddType video/avi .avi
    	AddType video/quicktime .mov .qt
    	AddType video/mp4 .mp4 .m4v
    	AddType video/mpeg .mpeg .mpg .mpe
    
    	# PDF
    	AddType application/pdf .pdf
    
    	# Flash
    	AddType application/x-shockwave-flash .swf
    
    	# Font
    	AddType application/x-font-ttf .ttf .ttc
    	AddType application/vnd.ms-fontobject .eot
    	AddType application/x-font-otf .otf
    
    	# Audio
    	AddType audio/mpeg .mp3 .m4a
    	AddType audio/ogg .ogg
    	AddType audio/wav .wav
    	AddType audio/wma .wma
    
    	# Zip/Tar
    	AddType application/x-tar .tar
    	AddType application/x-gzip .gz .gzip
    	AddType application/zip .zip
    </IfModule>
    
    <IfModule mod_expires.c>
    	ExpiresActive On
    
    	# Text
    	ExpiresByType text/css A31536000
    	ExpiresByType application/x-javascript A31536000
    	ExpiresByType text/html A3600
    	ExpiresByType text/richtext A3600
    	ExpiresByType text/plain A3600
    	ExpiresByType text/xml A3600
    
    	# Image
    	ExpiresByType image/gif A31536000
    	ExpiresByType image/x-icon A31536000
    	ExpiresByType image/jpeg A31536000
    	ExpiresByType image/png A31536000
    	ExpiresByType image/svg+xml A31536000
    
    	# Video
    	ExpiresByType video/asf A31536000
    	ExpiresByType video/avi A31536000
    	ExpiresByType video/quicktime A31536000
    	ExpiresByType video/mp4 A31536000
    	ExpiresByType video/mpeg A31536000
    
    	# PDF
    	ExpiresByType application/pdf A31536000
    
    	# Flash
    	ExpiresByType application/x-shockwave-flash A31536000
    
    	# Font
    	ExpiresByType application/x-font-ttf A31536000
    	ExpiresByType application/vnd.ms-fontobject A31536000
    	ExpiresByType application/x-font-otf A31536000
    
    	# Audio
    	ExpiresByType audio/mpeg A31536000
    	ExpiresByType audio/ogg A31536000
    	ExpiresByType audio/wav A31536000
    	ExpiresByType audio/wma A31536000
    
    	# Zip/Tar
    	ExpiresByType application/x-tar A31536000
    	ExpiresByType application/x-gzip A31536000
    	ExpiresByType application/zip A31536000
    </IfModule>
    <FilesMatch "\.(?i:css|js|htm|html|rtf|rtx|txt|xml|gif|ico|jpg|jpeg|jpe|png|svg|svgz|asf|asx|wax|wmv|wmx|avi|mov|qt|mp4|m4v|mpeg|mpg|mpe|pdf|swf|ttf|ttc|eot|otf|mp3|m4a|ogg|wav|wma|tar|gz|gzip|zip)$">
    	<IfModule mod_headers.c>
    		Header set Pragma "public"
    		Header append Cache-Control "public, must-revalidate, proxy-revalidate"
    		Header unset ETag
    	</IfModule>
    </FilesMatch>
    <FilesMatch "\.(?i:css|js|gif|ico|jpg|jpeg|jpe|png|pdf|swf|ttf|ttc|eot|otf)$">
        <IfModule mod_headers.c>
    		Header unset Set-Cookie
    	</IfModule>
    </FilesMatch>
    # END wtwp_cache
    
    # BEGIN wtwp_security
    <IfModule mod_rewrite.c>
    	RewriteEngine On
    	RewriteBase /
    	RewriteRule ^wp-admin/includes/ - [F,L]
    	RewriteRule !^wp-includes/ - [S=3]
    	RewriteRule ^wp-includes/[^/]+\.php$ - [F,L]
    	RewriteRule ^wp-includes/js/tinymce/langs/.+\.php - [F,L]
    	RewriteRule ^wp-includes/theme-compat/ - [F,L]
    </IfModule>
    <Files "wp-config.php">
    	Order allow,deny
    	Deny from all
    </Files>
    Options -Indexes
    # END wtwp_security

    link to site

Viewing 8 replies - 1 through 8 (of 8 total)
  • use simple redirect 301

    add this line at the end of your .htaccess

    Redirect 301 /oldpage.html https://www.yoursite.com/newpage.html

    Thread Starter lady_r0gue

    (@lady_r0gue)

    thanks for your quick reply – would I have to stipulate this for every existing page or is there a ‘catch-all’ solution I could use?

    you want to redirect all your domain including the folders inside?

    Thread Starter lady_r0gue

    (@lady_r0gue)

    I have a website where all the pages are named /mypage.html
    I’d like to redirect any typed /mypage.html pages to /mypage/

    Thread Starter lady_r0gue

    (@lady_r0gue)

    the website I linked is the new version. I want to build the new version of the website on the .net server and then move it to the .com server. I think it may be easier to redirect all of the /mypage/ links to pretend they are .html pages, like I did with the old one, huh. As pages ending .html are the ones currently ranking in google.

    wait.. before you said you want to change the .html to /
    so try this

    https://stackoverflow.com/questions/1472982/htaccess-redirect-all-html-files

    Thread Starter lady_r0gue

    (@lady_r0gue)

    Sorry it’s a little complicated. Originally my client had a static website on the .com server with page extensions like .php and .html. When I rebuilt it in cmsms I gave all the pages ‘pretend’ .html extensions and even redirected the old .php pages to give them what looked like .html extensions for the user.
    Now he has a separate hosting account on a .net server so I’m building a duplicate website on the .net server (as there’s only one database on the .com hosting account) – I’m planning to move everything over to the .com server once it’s done. Just didn’t want to break all the existing links to mysite.com/page.html and trying to think of the best workaround.

    ok, so create you website with your /%postname%/ permalinks, and create the redirects in the .htaccess file like in the link above.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘redirect .html to trailing slash’ is closed to new replies.