LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   extensionless url with https redirect (https://www.linuxquestions.org/questions/linux-server-73/extensionless-url-with-https-redirect-698590/)

ulver 01-20-2009 08:08 AM

extensionless url with https redirect
 
Ok, I have a site and a backend.php interface which is in https. I make it with the following;

Code:

<IfModule mod_rewrite.c>
  RewriteEngine On

  # force www if second level domain
  RewriteCond %{HTTP_HOST} ^([^\.]+)?\.([^\.]+)?$ [NC]
  RewriteRule .? http://www.%1.%2%{REQUEST_URI} [R=301,L]


 #https
  RewriteCond %{REMOTE_ADDR} !^127\.[0-9]+\.[0-9]+\.[0-9]+$
  RewriteCond %{HTTPS} !=on
  RewriteCond %{REQUEST_URI} (.*/backen.*)
  RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R]


</IfModule>


It works but I have just lost 5 hours trying to get extensionless php here so backend.php will read as backend or admin or whatever.

Anyone got any ideas please?

bathory 01-20-2009 04:08 PM

You might take a look at this post in mod_rewrite forum.

ulver 01-21-2009 04:54 AM

success
 
Thank you, it works now

Code:

<IfModule mod_rewrite.c>
  RewriteEngine On
  Options +FollowSymLinks +ExecCGI
  # force www if second level domain
  RewriteCond %{HTTP_HOST} ^([^\.]+)?\.([^\.]+)?$ [NC]
  RewriteRule .? http://www.%1.%2%{REQUEST_URI} [R=301,L]

  RewriteCond %{REMOTE_ADDR} !^127\.[0-9]+\.[0-9]+\.[0-9]+$
  RewriteCond %{HTTPS} !=on
  RewriteCond %{REQUEST_URI} (.*/backen.*)
  RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R]

  # Remove the .php from PHP files (only files
  # that exist).
  RewriteCond %{ENV:REDIRECT_STATUS} ^$
  RewriteCond %{SCRIPT_FILENAME} -f
  RewriteRule ^(.+)\.php$ /$1/ [R=301,L]

  # Rewrite /<name and /<name>/ to /<name>.php if
  # a PHP file exists and a directory does not.
  RewriteCond %{DOCUMENT_ROOT}/$1.php -f
  RewriteCond %{SCRIPT_FILENAME} !-d
  RewriteRule ^(.*[^/])/?$ /$1.php [QSA,L]



All times are GMT -5. The time now is 04:49 PM.