Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Rewrite URL - htaccess

Featured Replies

Hi everyone, I need help concerning the rewrite!

How should look Rewrite Rule for this link>

http://my-site.com/like.php?l=10

I want to look like this>

http://my-site.com/like/10

I believe it would be:

 

RewriteEngine on
RewriteRule ^like/(.*) /like.php?l=$1 [NC]

 

 

Let me know if it works :)

Edited by AlecIsh

  • Author

I believe it would be:

 

RewriteEngine on
RewriteRule ^like/(.*) /like.php?l=$1 [NC]

 

 

Let me know if it works :)

Thanks for the reply, but this don't work.

This isn't a static page, users can publish content and in fact this number behind is number of the post.

like.php?l=130

Edited by e><pert

Could you try

 

RewriteEngine on
RewriteRule ^like/([0-9]+)$ like.php?l=$1 [NC]

 

If this one doesn't work, we'd better tweak it some more. The [0-9] will mean that only numbers are allowed for the "l=" bit.

Forgot to say obviously you don't need the [NC] at the end if it's numbers only - sorry, forgot to whip that off.

  • Author

Thanks guys, but when I edit the file .htaccess don't change anything :(

  • Author

Check your server, you may not have mod rewrite enabled.

2je1mbc.jpg

Try setting a rewrite base. I'll asusme you're using xampp and have your site is accessible locally at

 

http://localhost/mysite

 

In your htaccess file try adding the following on the second line

 

RewriteBase /mysite

 

Ah yes the base always forget about that myself as well. Good call rallport.

  • Author

Try setting a rewrite base. I'll asusme you're using xampp and have your site is accessible locally at

 

http://localhost/mysite

 

In your htaccess file try adding the following on the second line

 

RewriteBase /mysite

I have this site live on the internet and page like.php is in the root folder along with. htaccess so you do not need to use those line, I don't know what was wrong, I contacted support and the operator told me that mod_rewrite is active by default on server...

This definitely works for me:

 

RewriteEngine On
RewriteBase /
RewriteRule ^like/([0-9]*)$ /like.php?l=$1 [L]

 

Screenshot of PHP fetching the 'l' variable using $_GET:

 

Qr9RC.png

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.