Taj Khan
Taj Khan

Reputation: 589

need to redirect all files from http to https plus need to remove .php extention from all files except few and also want to rewrite the urls

RewriteOptions inherit
DirectoryIndex index.php
#IndexIgnore *
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
RewriteRule ^about-us/?$   about-us.php  [NC]
RewriteRule ^domain-web-hosting/?$   domain-web-hosting.php  [NC]
RewriteRule ^graphic-creative-design/?$   graphic-creative-design.php  [NC]
RewriteRule ^logo-design/?$   logo-design.php  [NC]
RewriteRule ^email-design/?$   email-design.php  [NC]
RewriteRule ^banner-design/?$   banner-design.php  [NC]
RewriteRule ^website-design/?$   website-design.php  [NC]
RewriteRule ^static-website-design/?$   static-website-design.php  [NC]
RewriteRule ^dynamic-website-design/?$   dynamic-website-design.php  [NC]
RewriteRule ^corporate-website-design/?$   corporate-website-design.php  [NC]
RewriteRule ^ecommerce-website-design/?$   ecommerce-website-design.php  [NC]
RewriteRule ^cms-website-design/?$  cms-website-design.php  [NC]
RewriteRule ^responsive-website-design/?$  responsive-website-design.php  [NC]
RewriteRule ^website-maintenance/?$  website-maintenance.php  [NC]
RewriteRule ^website-redesigning/?$  website-redesigning.php [NC]
RewriteRule ^website-development/?$  website-development.php  [NC]
RewriteRule ^ecommerce-website-development/?$  ecommerce-website-development.php  [NC]
RewriteRule ^opencart-website-development/?$  opencart-website-development.php  [NC]
RewriteRule ^prestashop-website-development/?$  prestashop-website-development.php  [NC]
RewriteRule ^magento-website-development/?$  magento-website-development.php  [NC]
RewriteRule ^cms-website-development/?$  cms-website-development.php  [NC]
RewriteRule ^joomla-website-development/?$  joomla-website-development.php  [NC]
RewriteRule ^wordpress-website-development/?$  wordpress-website-development.php  [NC]
RewriteRule ^custom-website-development/?$  custom-website-development.php  [NC]
RewriteRule ^application-development/?$  application-development.php  [NC]
RewriteRule ^web-application-development/?$  web-application-development.php  [NC]
RewriteRule ^mobile-application-development/?$  mobile-application-development.php  [NC]
RewriteRule ^internet-marketing/?$  internet-marketing.php  [NC]
RewriteRule ^search-engine-optimization/?$  search-engine-optimization.php  [NC]
RewriteRule ^ppc-management/?$  ppc-management.php  [NC]
RewriteRule ^content-writing/?$  content-writing.php  [NC]
RewriteRule ^portfolio/?$  portfolio.php  [NC]
RewriteRule ^web-design-plans/?$  web-design-plans.php  [NC]
RewriteRule ^seo-plans/?$  seo-plans.php  [NC]
RewriteRule ^static-website-portfolio/?$  static-website-portfolio.php  [NC]
RewriteRule ^cms-website-portfolio/?$  cms-website-portfolio.php  [NC]
RewriteRule ^ecommerce-website-portfolio/?$  ecommerce-website-portfolio.php  [NC]
RewriteRule ^custom-web-development-portfolio/?$  custom-web-development-portfolio.php  [NC]
RewriteRule ^logo-portfolio/?$  logo-portfolio.php  [NC]
RewriteRule ^web-design-templates/?$  web-design-templates.php  [NC]
RewriteRule ^faq/?$  faq.php  [NC]
RewriteRule ^testimonials/?$  testimonials.php  [NC]
RewriteRule ^partner-with-us/?$  partner-with-us.php  [NC]
RewriteRule ^contact-us/?$  contact-us.php  [NC]
RewriteRule ^privacy-policy/?$  privacy-policy.php  [NC]
RewriteRule ^terms-and-conditions/?$  terms-and-conditions.php  [NC]
RewriteRule ^disclaimer/?$  disclaimer.php  [NC]
RewriteRule ^payment/?$  payment-options.php  [NC]
RewriteRule ^package-form/?$  package-form.php  [NC]
RewriteRule ^business-website-packages/?$  business-website-packages.php  [NC]
RewriteRule ^ecommerce-website-packages/?$  ecommerce-website-packages.php  [NC]
RewriteRule ^sitemap/?$  sitemap.php  [NC]

#RewriteCond %{HTTPS} off
#RewriteCond %{HTTP_HOST} ^(?:www\.)?(.*)$ [NC]
#RewriteRule ^(.*)$ https://www.websiteindia.net/$1 [R=301,L]

RewriteCond %{THE_REQUEST} ^.*/index.php
RewriteRule ^(.*)index.php$ https://www.websiteindia.net/$1 [R=301,L]

RewriteCond %{SERVER_PORT} ^80$
RewriteCond %{REQUEST_URI} !web-design-templates
RewriteCond %{REQUEST_URI} !/layouts
RewriteRule ^.*$ https://www.websiteindia.net%{REQUEST_URI} [R=301,L]

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

please see this my .htaccess file. Issue i have is .php files are also visible which i want to get redirected to non .php files.. except few files namely captcha.php and process.php. and also want to redirect all pages from https to non https i.e. http://www.websiteindia.net/web-design-templates as it has an iframe any help will be appreciated thank you.

Upvotes: 0

Views: 106

Answers (1)

Rijul Sudhir
Rijul Sudhir

Reputation: 2132

Please try the below code

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteRule ^([^/.]+)/? $1.php [L]

No need to add anything else. htaccess needs only this code and check if all your conditions are satisfied.

Upvotes: 1

Related Questions