skip to Main Content

Currenlty I am getting all data from MySQL database using following PHP query string:

ccroipr.php?id=201801161516084475

from this link:

<a href="ccroipr.php?id=201801161516084475">Profile</a>

Now

I want the URL should be ccroipr-201801161516084475

From this link

<a href="ccroipr-201801161516084475">Profile</a>

currenlty, Using following .htaccess rules:

RewriteEngine On
RewriteRule /(.*)/(.*)/$ ccroipr.php?id=$1

It’s accepting this URL:

ccroipr?201801161516084475

Not this one:

ccroipr-201801161516084475

How can I do this using .htaccess?

Update:

Ajax/jQuery Code

$('#register').submit(function( e ) {
    e.preventDefault();        
    var formData = $('form').get(0);    
    $.ajax({
        type : 'POST', 
        dataType : 'html',
        data: new FormData(formData),
        url : 'process/ccroipr-cat-p.php', 
        cache:false,
        contentType: false,
        processData: false,
        beforeSend : function () {
            $('#result').html( 'Please wait...' );
            $('#registerButton').prop('disabled', true);
        },
        success : function ( result ) {            
            $('#registerButton').prop('disabled', false);
            $('#result').html( result );
        }
    });
});

2

Answers


  1. You can use this rule using - as delimiter:

    Options -MultiViews
    RewriteEngine On
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^/?[^-]*-(.+?)/?$ ccroipr.php?id=$1 [L,QSA]
    
    Login or Signup to reply.
  2. Maybe you can try this, worked for me.

    RewriteRule ^site/([a-zA-Z])$ ccroipr.php?id=$1
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search