Take this link for example: http://example.com/p/12345
The 12345 part of the URL is a variable.
It should display like ?something=12345 but it doesnt so they are obviously using url rules/rematch. How do I view what the URL would be without the rules?
For example it might be something like http://example.com/p?number=12345
In a word, you can't. Unless you operate the web site and have access to the .htaccess file that is rewriting the URLs you can not determine exactly where it is being redirected.
In your example both the p and the 12345 could be variable.
Related
I need to do this using htaccess
When a request is made for http://www.example.com/home, it should (internally)load the page http://www.example.com/home_st.php
Similarly when a request is made to other link called products (http://www.example.com/products), it should (internally)load http://www.example.com/products_st.php
In short what it is doing is appending "_st.php" and loading that URL. But one thing I do not want is if the user directly types http://www.example.com/home_st.php or http://www.example.com/products_st.php in the browser, it should show 404 / Page not found error
I have few other pages in that folder and I want those pages to behave in this manner. I understand the htaccess should have something like this
Turn on the rewrite
Forbid access if the URL is called with page names like home_st.php, products_st.php etc.
If it's "home" or "products", then rewrite(append?) it to home_st.php and products_st.php respectively. I have other files too while need to follow the same
P.N: My URL should not show the actual filename, for example home_st.php, products_st.php etc. It should only show as http://www.example.com/home, http://www.example.com/products etc
htaccess and regex is not something that I am well acquainted with. Any help would be great. Thanks
You want to be able to re-write URL's
This has been written before but i'll say it again.
You want to use the Htaccess file and the re-write rule.
RewriteEngine On # Turn on the rewriting engine
RewriteRule ^pet-care/?$ pet_care_info_01_02_2008.php [NC,L] # Handle requests for "pet-care"
This will make this url: http://www.pets.com/pet_care_info_07_07_2008.php
Look like this: http://www.pets.com/pet-care/
Links to more information: How to make Clean URLs
and for the webpage I used to reference this information from: https://www.addedbytes.com/articles/for-beginners/url-rewriting-for-beginners/
To get your pages set the way you want them, I would advise that you read the two articals and try get what you are looking for.
If you need some specific help with doing this, ask.
Hope that helps.
I need help from someone with experience :)
I have noticed that lot of sites with SEO friendly urls like www.site.com/123456/some-title only take the value 123456 and doesnt matter the rest, htaccess just send the variable 123456 to the specific url and then the visitor see the content.
So, if I type
www.site.com/123456/some-title-1
www.site.com/123456/some-title-2
www.site.com/123456/some-title-3
www.site.com/123456/some-title-4
I will always see the same page because the id passed is always the same 123456.
But I saw a few sites correcting this. For example:
-If I type any of the 4 urls above, they show me the content BUT they redirect me to the right url (www.site.com/123456/some-title) first.
How can I do that? I think this is a php question, since they need to connect to the database to check the original "url path" for the id 123456, right?
If someone can give me a tip to do that would be great!
Thanks
How can I do that? I think this is a php question, since they need to connect to the database to check the original "url path" for the id 123456, right?
This is a PHP question. 2 things need to happen here. When someone requests:
www.site.com/123456/some-title-1
There is routing that happens in htaccess, something like (example rules):
RewriteRule ^([0-9]+)/(.*)$ /some.php?id=$1&slug=$2 [L]
So whatever the script is (some.php), it'll get two parameers, an ID and a slug. The ID is what it uses to do a lookup into a database or wherever the actual content is stored. When it fetches that information from the database, it can compare slugs. If they differ, then instead of serving the content, redirect the browser to show the correct slug. Then we start back over from the beginning, browser submits request (this time with the right slug for the ID), rewrite rule routes it to some.php and because the slug is correct, the actual content gets served to the browser.
When designing a website what would be good practice for the url designing and related backend.
Say I have a website with news posts on it. I would like the url to look like this:
mysite.com/news/newsItem1
Normally an url like this would reference to a folder called newsItem1 on the server. But in this case there will be a lot of newsItems (stored as xml files), and I don't think it's a good idea to create a folder for every item.
The same thing happens when I make the url like this:
mysite.com/news/newsItem1.html
In that case I would have to make a html file for every newsItem.
What I would like is an url that is different for every newsItem, but on the server it basically points to a php file that parses the matching xml file and returns its contents. How would I do that?
For this you have to use .htacces which allows you to redesign the url.
you can use something like this for that you want :
http://www.mysite.com/news/newsItem.php?id=1
and write the rewrite rule for url design in .htaccess file as:
RewriteEngine On
RewriteRule ^id/([^/]*)\.html$ /news/newsitem.php?id=$1 [L]
and the result will be as:
http://www.mysite.com/id/1.html
Here is the link for .htaccess tutorial
http://www.htaccess-guide.com/
I have a url as mydomain.com/store.php?id=3.
I would like to convert(redirect) to static URL on the base of id.
Replace the ID with the store name (from database) and add some hard coated keyword at the end of url.
URL should be look like this one mydomain.com/storename-keyword1-keyword2.html
Please guide me that what is the best way to do this? I have used a lot of my time to handle this issue but no result.
Thanks
Are you trying to do something like this? How can I make my urls friendly from this example?
That is, you are still serving the content using the script store.php but you want the browser's location bar to have a clean URL that looks like /storename/word/word.html? You're obviously going to need to change some of the rewrite matches and targets to suit the URLs that you want. Something like?
RewriteRule ^storename-([^\-]+)-(.+).html /store.php?id=$1&something=$2&rewritten=true [L]
I have a build a web portal based on the Cricket concept,
I have build a Custom based CMS where I can upload the News for the site
Once I upload the news, the URL Will be like this
http://cricandcric.com/news/news.php?id=841&An-emotional-moment:-Dhoni.html
But I am trying to have the above Url as follows (some thing like this)
http://cricandcric.com/news/An-emotional-moment:-Dhoni.html
Or similar to Stackoverflow.com,
Can any one please help me how can i build that?
Do I need to rewrite the URL ?
Yes, this is typically done with URL rewriting. This is a great intro to it.
Note that you'll have to make sure that the titles are unique, if you're removing the ID from the URL. (And you might as well get rid of the ".html" too)
Yes, as far as I can see you need to rewrite the URL. The URL "http://cricandcric.com/news/An-emotional-moment:-Dhoni.html" might be rewritten to "http://circandcric.com/news/index.php?title=An-emotional-moment:-Dhoni". Then, index.php has to figure out the correct news item from this title. This might be a source of problems (transformation of the title into URL-compatible string and back again), and, as Chad pointed out, the title has to be unique. If you get into trouble, check out how Stackoverflow handles this (ID as part of the URL, then title).
yeah Dude, .htaccess file will resolve all your Riddles.....Chk This--- How to use .htaccess file for rewriting URL?