skip to Main Content

I want to change my url to search engine friendly. i am using xampp 3.2.1 on windows 10 with 64-bit
My URLs are looking like this:

http://smc.edu.pk/app/site/?p=12&m=c&u=Swat_Medical_College-_The_Project_of_Swat_Medical_Complex

And I want to make it like this:

http://smc.edu.pk/app/site/12/c/Swat_Medical_College-_The_Project_of_Swat_Medical_Complex.html

i have tested with the following code with .htaccess

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/app/site/(d+)/([a-z-]+)/(.+).html$ /?p=$1&m=$2&u=$3 [NC,L]

but it returns the following error when i am using the second url mentioned above:

Object not found!

The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again.

If you think this is a server error, please contact the webmaster.

Error 404

smc.edu.pk
Apache/2.4.12 (Win32) OpenSSL/1.0.1l PHP/5.6.8

2

Answers


  1. Chosen as BEST ANSWER

    Yes, i have found the solution:

    RewriteEngine On
    RewriteBase /app/site/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^([^/]+)/([^/]+)/([^/]+).html$ /app/site/?p=$1&m=$2&u=$3 [NC,L]
    

    I have change the RewriteRule to:

    RewriteRule ^([^/]+)/([^/]+)/([^/]+).html$ /app/site/?p=$1&m=$2&u=$3 [NC,L]
    

    And also put the RewriteBase /app/site/ on second line. Now its working perfectly....


  2. I think it should be like this(not tested):

    RewriteRule ^/app/site/(d+)/([a-z-]+)/(.+).html$ /app/site/?p=$1&m=$2&u=$3 [NC,L]
    

    Edit: It should be like this (tested and working):

    RewriteRule ^app/site/(d+)/([a-z-]+)/(.+).html$ /app/site/?p=$1&m=$2&u=$3 [NC,L]
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search