skip to Main Content

Hi I am trying to change my url using htaccess but it didn’t work anymore.

http://localhost:8888/cPanel/abc?page=general-settings

RewriteRule ^cPanel/([w-]+)/?$ abc.php?page=$1 [L,QSA]

What i am doing wrong anyone can help me here please ?

I want to change the url like this:

http://localhost:8888/cPanel/general-settings

<?php 
$page ='';
if($_GET['page']){ 
    $page = $_GET['page'];
 if($page == 'general-settings'){
     include "/pages/general-settings.php" ;
 }
}
?>

2

Answers


  1. Test this code

    RewriteEngine on
    Options +FollowSymlinks
    RewriteRule ^cPanel/(.+)/?$ abc.php?page=$1
    

    url: http://localhost:8888/cPanel/general-settings

    Login or Signup to reply.
  2. The error stands in the rule. Your actual rule is:

    RewriteRule ^cPanel/([w-]+)/?$ abc.php?page=$1 [L,QSA]
    

    which is missing cPanel, if you want to achieve http://localhost:8888/cPanel/general-settings as result

    With this rule (which means: when you Apache match cPanel/*anything*, hit the resource at cPanel/abc.php?page=*anything*) it should work:

    RewriteRule ^cPanel/(.*)$ cPanel/abc.php?page=$1 [L,QSA]
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search