johnsmith153 Posted May 19, 2012 Share Posted May 19, 2012 This rewrites to index.php: RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L,NS] ...and I just can't get it to also redirect (301) to https://www.domain.com/page/var/ etc (with trailing slashed and https). Quote Link to comment https://forums.phpfreaks.com/topic/262795-impossible-redirect-any-url-to-httpswwwdomaincom-and-rewrite-to-indexphp/ Share on other sites More sharing options...
ignace Posted May 20, 2012 Share Posted May 20, 2012 Can you post your code. PS Apache has a special directive for your rewrite to index.php FallbackResource From Apache Docs: It is frequently desirable to have a single file or resource handle all requests to a particular directory, except those requests that correspond to an existing file or script. This is often referred to as a 'front controller.' In earlier versions of httpd, this effect typically required mod_rewrite, and the use of the -f and -d tests for file and directory existence. This now requires only one line of configuration. Quote Link to comment https://forums.phpfreaks.com/topic/262795-impossible-redirect-any-url-to-httpswwwdomaincom-and-rewrite-to-indexphp/#findComment-1346974 Share on other sites More sharing options...
johnsmith153 Posted May 20, 2012 Author Share Posted May 20, 2012 Hi, So far, I have this. It works, but I'm guessing I could improve on it a bit. It does work though as it is. I am using the Rackspace Cloud server, which I believe has the need for some slight adjustments. RewriteEngine On # required on my server RewriteBase / # redirect to full correct url if missing trailing slash RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_URI} !(.*)/$ RewriteRule ^(.*)$ https://www.domain.co.uk/$1/ [R=301,L] # redirect to full correct url if not complete rewritecond %{http_host} ^domain.co.uk [nc,OR] # the next line may be specific to my server RewriteCond %{ENV:HTTPS} !on [NC] RewriteRule ^(.*)$ https://www.domain.co.uk/$1 [R=301,L] # use index.php for all requests RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . index.php [L,NS] Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/262795-impossible-redirect-any-url-to-httpswwwdomaincom-and-rewrite-to-indexphp/#findComment-1346988 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.