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.

mod_rewrite working on my localhost but not livehost...

Featured Replies

For some reason this is working exactly how I wanted it to on my testing machine but when I upload it to the server it doesn't work.

 

My preg match expression is as follows...

 

RewriteRule ^u/([a-z0-9_.]+)/?([a-z]*)/?([0-9]*)$ profile.php?username=$1&page=$2&msgNum=$3 [NC]

 

/u/adam correctly redirects to profile.php?username=adam

 

/u/adam/messages fails to redirect to profile.php?username=adam&page=messages

 

/u/adam/messages/2 fails to redirect to profile.php?username=adam&page=messages&msgNum=2

 

I'm sure they syntax of the preg_match is correct because I am using the star which means 0 or more, and it works absolutely fine on my localhost (ZendServer CE), it just breaks when on my live server.

 

Where should I be looking for this problem?

  • Author

got that covered I think

 

above my RewriteRules I have...

 

 

Options +FollowSymLinks

RewriteEngine On

RewriteBase /

  • Author

Try this regex instead

^u/([^/]+)(??:/([a-z]+))(?:/([0-9]+))?)?/?$

 

Could you explain this please???

 

The problem I'm having is that it works on my local host but not the live host... so there must be something different about the live host.

Here's the full breakdown of the regex

^u/([^/]+)(??:/([a-z]+))(?:/([0-9]+))?)?/?$

Options: case insensitive; ^ and $ match at line breaks

Assert position at the beginning of a line (at beginning of the string or after a line break character) «^»
Match the characters “u/” literally «u/»
Match the regular expression below and capture its match into backreference number 1 «([^/]+)»
  Match any character that is NOT a “/” «[^/]+»
     Between one and unlimited times, as many times as possible, giving back as needed (greedy) «+»
Match the regular expression below «(??:/([a-z]+))(?:/([0-9]+))?)?»
  Between zero and one times, as many times as possible, giving back as needed (greedy) «?»
  Match the regular expression below «(?:/([a-z]+))»
     Match the character “/” literally «/»
     Match the regular expression below and capture its match into backreference number 2 «([a-z]+)»
        Match a single character in the range between “a” and “z” «[a-z]+»
           Between one and unlimited times, as many times as possible, giving back as needed (greedy) «+»
  Match the regular expression below «(?:/([0-9]+))?»
     Between zero and one times, as many times as possible, giving back as needed (greedy) «?»
     Match the character “/” literally «/»
     Match the regular expression below and capture its match into backreference number 3 «([0-9]+)»
        Match a single character in the range between “0” and “9” «[0-9]+»
           Between one and unlimited times, as many times as possible, giving back as needed (greedy) «+»
Match the character “/” literally «/?»
  Between zero and one times, as many times as possible, giving back as needed (greedy) «?»
Assert position at the end of a line (at the end of the string or before a line break character) «$»


Created with RegexBuddy

 

So you're saying that that doesn't work on your server either?

  • Author

Well it did work... but my other one has started working again now too, maybe the server was just messing up, it went down for 6 hours not long after...

 

which regex would be the better one to use?

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.