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.
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 2 years ago.
Improve this question
I am currently writing an app where you can add a comment to a post based on IdTicket.
<td>Comments</td>
I am passing the Id value in my URL which is a part of the table. It is a dynamic value, different for every ticket. I am using $_GET['IdTicket'] on the comment.php page to get the id and based on that write a comment.
Is there a way to rewrite that link in htaccess? It would be perfect to hide everything or just make it prettier. And how would it look applied to that table?
Sure that is possible. And there are already countless examples for this...
You need to change the reference you hand out in your spplication logic:
Comments
And you need to take care to internally rewrite the incoming request to the actual resource again:
RewriteEngine on
RewriteRule ^/?comments/(\d+)$ /comments.php?IdTicket=$1 [QSA,END]
Obviously the rewriting module needs to be loaded. And if you want to use distributed configuration files (instead of the real host configuration inside the http server) you also need to have enabled the interpretation of those for host and location.
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
Very fundamental question
I have phplist project set-up in net beans. URL I am accessing is
http://example.com/admin/ and
all the files are under list folder.
In debugging I can see that all the times execution starts from index.php file in lists folder.
What I am not getting is how does the particular php file associated with URL gets executed.
Meaning
http://example.com/admin/
should execute admin.php, but how does the execution goes to admin.php
if you enter only the file path like you did, it runs the index.php file, if you want to run any file in the folder, append the filename to the path like this: http://example.com/admin/admin.php
Typically with applications like this, all of the page accesses are routed through the index.php script, which examines the URL and maps/routes the request to the correct script based on what it contains.
A quick peek at the source of phplist makes it seem like that is indeed what is going on - look at the index.php for more detail.
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 is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
As the title states, I've run into a few incoming traffic sources that are adding /trackback/ on the end of some of my URLs. The pages load fine due to my existing htaccess which grabs the dir name... But I don't want to generate tons of duplicate content with and without the /trackback/ addition. These incoming hits need to drop the /trackback/ off the end. What is the best way you would accomplish this without changing incoming links/sources?
I'm currently using php to check $_SERVER['REQUEST_URI'] and redirect back to the same URL without /trackback/ but I'm sure htaccess would be much faster because it wouldn't need to process the php engine of my site twice...
The easiest solution is a 301 redirect, which will flag the URL in most crawlers as if the URL they found (with /trackback/) permanently redirects to the version without. This would allow you to not have Google flag your content as duplicate.
You can do this using rewrite:
RewriteRule ^(.*)/trackback/$ $1 [R=301,L]
This will flag anything with /trackback/ at the end as a redirect to the page without.
NOTE: those hits are most likely bots looking for blogs with automated trackback acknowledgement in order to publish more links.
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.