• Jobs
  • About Us
  • Jobs
    • Home
    • Jobs
    • Courses and challenges
  • Businesses
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

302
Views
How to redirect url with forward slash in .htaccess?

I'm trying to redirect my url:

www.site.com/dashboard/invest-package.php?packageID=1

to

www.site.com/dashboard/invest-package/1

Actually I solved this problem with -

<a href="invest-package-'.$row['packageID'].'">Invest</a>

RewriteRule ^invest-package-(.*)$ invest-package.php?packageID=$1 [QSA,L]

But I wanted to make with "/" don't like using "-". Solutions I found on the internet didn't work. I keep getting 404 not found error.

Here is my link to invest-package.php

<a href="invest-package/'.$row['packageID'].'">Invest</a>

and .htaccess file:

Options -Indexes
RewriteEngine On

RewriteBase /dashboard/

RewriteCond %{REQUEST_FILENAME} !-d [NC]
RewriteCond %{REQUEST_FILENAME} !-f [NC]

RewriteRule ^invest-package/(.*)$ invest-package.php?packageID=$1 [QSA,L]
over 3 years ago · Santiago Trujillo
1 answers
Answer question

0

You may try this code:

Options -Indexes -MultiViews
RewriteEngine On
RewriteBase /dashboard/

RewriteCond %{REQUEST_FILENAME} !-d [NC]
RewriteCond %{REQUEST_FILENAME} !-f [NC]
RewriteRule ^invest-package/([\w-]+)/?$ invest-package.php?packageID=$1 [QSA,L,NC]

It is important to turn off MultiViews i.e. the content negotiation service of Apache.

Option MultiViews (see http://httpd.apache.org/docs/2.4/content-negotiation.html) is used by Apache's content negotiation module that runs before mod_rewrite and makes Apache server match extensions of files. So if /file is the URL then Apache will serve /file.php without any GET parameters.

over 3 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Show me some job opportunities
There's an error!