htaccess transform contact.php in contact?
I have tried this to transform index.html to index but is not working
RewriteRule ^index\.html$ http://localhost/Seaweb/index/ [R=301,L]
any help apreciated
htaccess transform contact.php in contact?
I have tried this to transform index.html to index but is not working
RewriteRule ^index\.html$ http://localhost/Seaweb/index/ [R=301,L]
any help apreciated
was on the right track: use mod_rewrite so a clean path like /contact maps to contact.php. For a reliable, SEO‑friendly setup do two things: 1) redirect external requests for contact.php to the clean /contact (301) so search engines only index one URL, and 2) internally rewrite /contact to serve contact.php so the user sees the clean URL while the file is executed.
Example rules to put in the site root .htaccess (disable MultiViews first, redirect before the internal rewrite):
Options -MultiViews
RewriteEngine On
RewriteBase /
# canonical redirect: /contact.php -> /contact
RewriteCond %{THE_REQUEST} \s/+contact\.php[?\s] [NC]
RewriteRule ^contact\.php$ /contact [R=301,L]
# internally serve contact.php when /contact or /contact/ is requested
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^contact/?$ contact.php [L,QSA] To generalize (as noted), you can map many names to their .php files with a single rule that captures the slug and rewrites to slug.php. Common pitfalls: ensure mod_rewrite is enabled (Debian/Ubuntu: sudo a2enmod rewrite and restart), AllowOverride All is set for the directory, turn off MultiViews if present, and remember 301 redirects are cached by browsers — test in a private window. See the Apache mod_rewrite and .htaccess documentation for details: mod_rewrite docs and htaccess howto.
Jump to Post— pritaeas 2,276What is the name of the actual file, I guess index.html ?
RewriteRule ^index$ index.html [R=301,L]So when you now use
indexin the URL,index.htmlwill be called.
What is the name of the actual file, I guess index.html ?
RewriteRule ^index$ index.html [R=301,L]
So when you now use index in the URL, index.html will be called.
yes this is what I am looking for and furthermore this method can be aplied for the rest of the links as well
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.