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.

.htaccess rewrite exception?

Featured Replies

I would like my site to be .com/username

 

but I also want my pages to be .com/signup

 

I know that I could make it .com/user/username but I would prefer if I could use the first method, what would I need to do to make exceptions, this is what I have so far...

 

Options +FollowSymLinks
RewriteEngine On
RewriteBase /

RewriteCond %{SCRIPT_FILENAME} !-d  
RewriteCond %{SCRIPT_FILENAME} !-f

RewriteRule ^([a-z0-9_.]+)*$ profile.php?username=$1 [NC]

 

At the moment it is taking any /anything and redirecting to profile.php

Edited by adamsmith

You're basically going to have to put a "router" between the /xyz and your destination page. In the router you need to get the string, check if it's a page. If it is, display that. If it's not you'd show the profile page. The router simply needs to include the relevant .php file

  • Author

You're basically going to have to put a "router" between the /xyz and your destination page. In the router you need to get the string, check if it's a page. If it is, display that. If it's not you'd show the profile page. The router simply needs to include the relevant .php file

How would I go about doing that in the .htaccess file? Is it worth it or will that add (significant) load time to each page?

  • Author

I do keep meaning to learn codeignighter but I just always find myself writing out from scratch and think I'll just change it later, but I never do.

<IfModule mod_rewrite.c>
   RewriteEngine On
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteRule ^(.*)$ app.php [QSA,L]
</IfModule>

SetEnv APPLICATION_ENV development

 

<?php

require_once __DIR__.'/../app/AppKernel.php';


define('ROOT_DIR',realpath(realpath(__DIR__.'/..')));

$app = new Kernel();
$app->dispacheRequest();

 

    public function dispacheRequest() {


       $this->getMethodRoute('homepage');



       $match = false;

       foreach($this->routes as $route) {

           if (!isset($route['pattern'])) {
               continue;
           }

           if (preg_match('/'.$route['pattern'].'/', $_SERVER['REQUEST_URI']) >0) {

               if (isset($route['headers'])) {
                   foreach($route['headers'] as $header) {
                       header($header);
                   }
               }

               if (isset($route['include'])) {
                   include ROOT_DIR.DIRECTORY_SEPARATOR.$route['include'];
               }

               $match = true;
           } 
       }

       if (!$match) {
           header($this->routes['404']['headers'][0]);
           include ROOT_DIR.DIRECTORY_SEPARATOR.$this->routes['404']['include'];
       }

   } 

 

Try something like that? They are just snippets from a little framework I have started..

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.