SEO URL for dynamic arabic URL using PHP

I currently have such a URL

domain / index.php? Cat = مال_وأعمال

I want to set everything up so that our marketing professionals can post a URL, like

domain / مال_وأعمال

I have tried several solutions, including:

mod_rewrite - the problem with this approach is that it becomes a huge .htaccess file, since we need to write a rule for each category.

RewriteMap is pretty close, since I could query the database to create a map file for output. However, since then I found out that we do not have access to httpd.conf.

index.php - I tried to run everything through our index.php file, which works, but does not support a browser friendly URL for SEO purposes.

I hope someone has another idea that could help, I would really appreciate it. If you have a link to something on the Internet that helps, that will be great too.

php.htaccess mod-rewrite seo-friendly

+1
source share
3 answers

You can use the following rule to match each query in which the URI path contains only one path segment on index.php, excluding existing files:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^[^/]+$ index.php?cat=$0 [L]

Please note that you really need to request /مال_وأعمالthat it be internally rewritten to /index.php?cat=مال_وأعمال.

+1
source

First of all, you need to create a catch subdomain that will send all requests to your only VirtualHost:

ServerAlias *.website.com

Then you can:

  • HTTP , ( , 301 www.
  • mod_rewrite URL-, .
0

mod_rewrite. - [L], mod_rewriting . , "index.php", "about_us.php" "contact_us.php", -, , . - :

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule index\.php index.php [L]
RewriteRule about_us(\.php)? about_us.php [L]
RewriteRule contact_us(\.php)? contact_us.php [L]
RewriteRule (.*) index.php?cat=$1
</IfModule>

That way, if they switch to index.php(or just index), they will get your index.php file. If they go to about_us.php(or just about_us), they get your about_us.php file. But if they go to test(which was not indicated in the first three lines), they are redirected toindex.php?cat=test

0
source

All Articles