Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
How could I send an error to the person who tries to connect to my site?
More specificaly, an error that says the site is offline or does not exist.
Example: when you go to: http://aoihjehopejhoitjaephjo.com you'll see "This site is unreachable"
I need my site to show that page.
Does anyone know, how / if it's possible to achieve this?
for a screenshot on the error I need: https://gyazo.com/2c7926238572e73f2757db577bb16bae
If you can use .htaccess you can insert the following lines:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
Redirect 500 /
</IfModule>
This will redirect everyone to the internal server error page. You can change 500 to any of the other error codes which can be found using a search engine, or to a directory/page you've created specifically for people to see.
I did it by redirecting my main domain: www.domaindomain.com/index.html to www.domaindomain.com/file.html.
My file.html will display an error message.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I would like to prevent users to view the contents of all html files.
Example:
website.com/join/view_template.html (and it will display all the codes including the smarty)
I would like them to be redirected to 404 page if they do this.
I'm not sure if this is possible in htaccess.
You can use the following line in htaccess :
RedirectMatch 404 ^/.+\.html
This will return 404 not found error for all .html files.
Try it like this although I didn't try it for now,
RewriteEngine On
RewriteRule \.html - [R=404]
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
Some days back, I have changes WordPress URL's to URL.html via .htaccess. I Know it was very smart move. As google crawled all tne pages, but there were too much 404 error in Webmaster Tools. After some days later I have removes .html from URL. but the real problem happens later.
Now my problem is:
I want to changes the URL.html/comment-page-1 to URL/comment-page-1 (default). I am not good with .htaccess. So please help me.
You can use this redirect rule before other wordpress rules:
RewriteRule ^([^.]+)\.html/(.*)$ /$1/$2 [L,NC,NE,R=301]
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I want to make a redirect in case people didn't type in the complete link to my subdomain, something like:
28cup.mpkosis28.com/ to redirect to 28cup.mpkosis28.com/index.html
I tried to make a default redirect in cpanel, but it still won't redirect.
EDIT: So I made a subdomain: http://28cup.mpkosis28.com/index.html. The problem is that I have to add the /index.html every time I want to access the site without going to mpkosis28.com first. I don't want to tell people that they have to add the /index.html if they want to go directly into the site, I can just tell them to go to 28cup.mpkosis28.com which redirects to 28cup.mpkosis28.com/index.html.
Sorry for not adding more details in the question, it's because of some question "guidelines".
If on an Apache server, create a file called .htaccess and insert the following:
Redirect http://28cup.mpkosis28.com/ http://28cup.mpkosis28.com/index.html
then upload in ASCII format in either the root of the sub-domain, and/or the root of mpkosis28.com
You can also try using:
DirectoryIndex index.html
Put the code below in the head of your the index or the default page visitor would normally go.
<meta http-equiv="refresh" content="0; URL=http//subdomain.domain.com">
For instance if when visitors type www.domain.com you want them to be redirected to http//subdomain.domain.com you will put http//subdomain.domain.comas the value of the URL in the code.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I need help to get this done.
My webpages have formatted urls in this pattern: "http://qifu.us/index.php?page=item&id=4" for example - if there are more pages, only the last page id number will be different.
I want to get this part "index.php?page=item&id=" out, and shortened like "http://qifu.us/s4", when a user input the shortened url into to address bar, it will be directed to the right page, which is the true url.
I am thinking to save the STATIC part "index.php?page=item&id=" into a string variable, and append the DYNAMIC page id - which is 4 in this example, then use Javascript or PHP to direct to the right page. But I don't know how the steps, pls help. Thanks.
Actually an htaccess will be very good for this purpose.
For urls like http://qifu.us/s4 do the following: Create a file with name .htaccess and place at your root directory with the following content.
RewriteEngine On
RewriteRule ^s([^/]*)$ /index.php?page=item&id=$1 [L]
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I am trying to build a simple URL shortner and I have come across a few complications:
A) in .htaccess how would I rewrite mydomain.com to make it so users can enter mydomain.com/4854 while the page is actually mydomain.com/url.php?key=4854.
B) If I do have that Rewrite rule how can I be sure to bypass it for index.php and add.php
Thanks so much in advanced.
In your .htaccess you can do:
RewriteEngine On
RewriteRule ^([0-9]+)(/)?$ /url.php?key=$1 [QSA,L]
This rewrites requests that contain only numbers to url.php.
Then in url.php, if key is not found, redirect to error page.
RewriteEngine on
RewriteRule ^([0-9]+)(/)?$ url.php?key=$1
And if the key is invalid, redirect in the php file
Let me save you the grief...I was doing the same thing, and found it written for me at yourls.org. It covers pretty much everything you need, as well as giving you option user pages to add their own, AND gives you an API interface for others to use the shortened URLS. I had it up and running in minutes, and spent a couple of hours modifying the samples given to be ready for production.
Even if you don't use it, the mod_rewrite solution is there for you.