skip to Main Content

I need some help with htaccess. Would you be so kind to assist a little bit?
I have a URL like this

https://example.com/index.php?p=application-intelligence
[or]
https://example.com/?p=application-intelligence

Basically the index.php is passed some parameter ‘home’ to know which page to load i.e. home.php
So I’ve tried to follow your post on your blog but with not much luck.

So I’d like the final code to be

https://example.com/application-intelligence

Here’s my code.

RewriteEngine on 
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/?$ index.php?p=$1

Also for the
https://example.com?p=home

I’d like it to be just

https://example.com

2

Answers


  1. This is what i have in my apache virtual host conf file:

    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-l
    RewriteRule ^(.*)$ index.php?$1 [L,QSA]
    
    Login or Signup to reply.
  2. You may use these rules:

    RewriteEngine on
    
    # handle /?p=home
    RewriteCond %{THE_REQUEST} s/+(?:index.php)??p=homes [NC]
    RewriteRule ^ /? [R=301,L,NE]
    
    # handle /?p=<something>
    RewriteCond %{THE_REQUEST} s/+(?:index.php)??p=([^s&]+) [NC]
    RewriteRule ^ /%1? [R=301,L,NE]
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^([^/]+)/?$ index.php?p=$1 [L,QSA]
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search