I am trying to get a landing page to work while I am doing scheduled updates on my site.
So basically all my original files will still exist in the directory including my index.php file but I've added another index1.html, so whenever I do an update I just want to be able to un-comment a line in my .htaccess file and everything will redirect to the landing page.
In my .htaccess file I have:
Options -MultiViews
RewriteEngine on
RewriteRule ^(.*)$ index1.html?path=$1 [L,NC,QSA]
This works for me in so far as any file or sub-directory I go to like example.com/whatever will redirect but example.com will still go to the original index.php which is what I want to be updating.
This line did exactly what I wanted:
DirectoryIndex index1.html
Related
Simple as the question. I want to change my website's default page from index.php to index.html. I don't know if my server (000webhost.com, while website is under development) uses Apache, but I've changed the .htaccess file, and added DirectoryIndex index.html index.php. Still not working, though.
When the website loads, it loads randomwebsitename12345.com. If I add /index.html to the string, then the page loads fine, as it should. If I remove the .php file from my server, then the website loads index.html.
Any ideas?
Why not just remove index.php from the .htaccess file?
You can use the following rewrite rule to set index.html as your homepage :
Add this before other rules in your htaccess :
RewriteEngine on
RewriteRule ^$ /index.html [L]
This is the case:
You can request a demo for a specific product online. That's what we will do:
We will create a subdomain on our server and clone + install the code of our online product. A cron runs every day and when your subdomain exists 14 days we want to place an index.html in the subdomain with some info on it.
Now the problem is that the index.html doesn't do anything. In our .htaccess we have the following:
Options -Indexes
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* index.php
As you can see we have a RewriteRule to index.php otherways the code doesn't work. How can I make sure that the index.html is loaded.
Also another problem is that when you're logged in you're automatically go to /admin, so if there's no admin folder he will give an error.
How can I make this work?
Try putting DirectoryIndex index.html into your .htaccess.
See https://httpd.apache.org/docs/2.2/mod/mod_dir.html#directoryindex
Currently my .htaccess file reads:
DirectoryIndex dice.php
Dice.php is a loading page which has an iframe in (index.php) which eventually when finished loading breaks the iframe and fills the page. However it fills it as https://example.com/index.php in the url.
I want it to fill as https://example.com/play.
Anyone have any ideas?
Try adding this to your .htaccess file
RewriteEngine On # Turn on the rewriting engine
RewriteRule ^play/?$ index.php [NC,L]
I have a website, say http://mysite.com. I would like to put index.php in a subdirectory, public_html/mysubdir/index.php. I would like public_html/mysubdir/index.php to get executed when the user goes to http://mysite.com. And I would like the url to continue to read http://mysite.com. Is this possible?
If your webserver is Apache you could use URL rewriting with mod_rewrite.
Another option is to create an index.php in the root directory and include index.php in the sub directory.
Rewrite rules may be overkill for this depending on what you want. For just your main index page, this will work...
Simply adding this one line to your .htaccess file:
DirectoryIndex mysubdir/index.php
It will display the page located at mysubdir/index.php while simply showing http://mysite.com in the URL.
I use this method myself. While all of my pages are located in the same subdirectory, the home page is displayed with my domain name by itself (http://www.mysite.com). All other pages show the full URL.
If you also have index pages within deeper subdirectories and want those to come up by default within the subdirectory.
Example:
If you want this page: http://mysite.com/mysubdir/anothersub/index.php
to come up with this URL: http://mysite.com/mysubdir/anothersub/
Then modify the line with another index.php like this...
DirectoryIndex mysubdir/index.php index.php
What this does is tell the server to look for files with those names in that same order. If it can't find the first, it tries the second, and so on.
When you're inside your root at / it finds and then displays mysubdir/index.php.
When you're inside another subdirectory like /mysubdir/anothersub/, it can't find anything named mysubdir/index.php so it goes to the next item and displays index.php
You could use a .htaccess file and define Rewrite rules.
http://httpd.apache.org/docs/current/mod/mod_rewrite.html
Make sure that mod_rewrite is enabled and then place .htaccess file in your root directory with something like this:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ your_subdir/index.php/$1 [L]
</IfModule>
i have a domain with a website in a folder.
i.e
http://domain.com.au/website/page.php
i only have access to .htaccess files to make the rules.
i would like my url to look like this..
http://domain.com.au/page
so in essence i want to drop the subfolder its sitting in, and the php extention.
All links in my php are structured like this though
page link
this is the same for js and css. they are all referenced from the 'website' folder.
will the rewrite mean i have to change all my links?
priority is dropping the folder from the url, not so much the php extension.
1) You could move all the files to the root web directory and run the website from there.
2) You would have to manually modify every link to remove the website directory from the beginning and then use the .htaccess file to redirect the pages back to the appropriate page. If you're going to do it this way, you might as well remove the PHP extension...
RewriteEngine On
Options +FollowSymLinks
RewriteCond %{HTTP_HOST} ^domain.com.au$ [NC]
RewriteRule ^(.*)/ website/$1.php [L]
You may have to modify the website/$1.php part to include your entire root directory in some cases, but that should work as long as the .htaccess file is in the root web directory. That will redirect any page in the form 'http://domain.com.au/page' to 'http://domain.com.au/website/page.php' while keeping the URL the same in the address bar.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^page\_one/(.*)/([0-9]{1,6})/?$ webroot/products/products/view/$2 [L]
</IfModule>
this htaccess code redirects all trafic from www.domain.com/page_one/anything/numeral
to the page www.domain.com/webroot/products/products/view/same numeral
for your example, something like
RewriteRule ^page?$ website/page.php$2 [L]
note, this works for "page" as a string, if you need other functions , change it
for more insight, you might want to take a look at this link :
http://www.javascriptkit.com/howto/htaccess.shtml