0

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

  1. Turn on the rewrite
  2. Forbid access if the URL is called with page names like home_st.php, products_st.php etc.
  3. 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

R.W
  • 530
  • 1
  • 12
  • 34
  • I think this is not possible, because if you redirect your orignal files to 404 ,then rewritten url will also point to 404. – Amit Verma Dec 11 '15 at 13:00

1 Answers1

2

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.

Community
  • 1
  • 1
simonr2
  • 66
  • 8