.htaccess,pagination,seo,yii2 , Removing the number of first page in Yii2 Pagination from the URL


Removing the number of first page in Yii2 Pagination from the URL

Question:

Tag: .htaccess,pagination,seo,yii2

For SEO purposes I need to remove the first page number from the URL. i.e I have the following:

example.com/pages/view/1 and example.com/pages/view the two URLs points to the same contents of the view action. I want to make the pagination free from 1 in the URL. i.e first Page link and Page Number 1 should be linked to pages/view.

I tried to deal with the $pagination object like the following:

$pages = new Pagination(['totalCount' => $books['booksCount'], 'pageParam' => 'start', 'defaultPageSize' => 10,]);
      $pagingLinks = $pages->getLinks();
      $pagingLinks['first'] = '/';
      $pages->links = $pagingLinks;

However, the last line causing error:

Setting read-only property: yii\data\Pagination::links

So I have a problem to modify the links property. Is there any other solution to get this task done?!


Answer:

According to docs you should set yii\data\Pagination::forcePageParam to false by passing it in Pagination constructor

$pages = new Pagination([
    'totalCount' => $books['booksCount'], 
    'pageParam' => 'start', 
    'defaultPageSize' => 10,
    'forcePageParam' => false,
]);

Related:


How to write .htaccess file for AJAX page


php,jquery,ajax,.htaccess
I am working on a website which i am going to develop as a CMS. So i am writing .htaccess file. page link and url working fine, but when i performing ajax request then i am getting 404 error for the url. I am placing my .htaccess file code and...

Flask: [405 error] with pagination and POST request


python,flask,pagination
I have a Flask app with a route that uses pagination and has to handle GET and POST requests. I defined two routes for my function as described here to get the pagination working. When I post a form on a page other than the first then I get a...

htaccess rewrite rules conflict


php,.htaccess,url,mod-rewrite
www.example.com/category/sub_category/Having problem with the rewririte rules in .htaccess file. my current .htaccess file looks like this. RewriteRule ^([0-9a-zA-Z_-]+)/([0-9]+)$ products.php?cat=$1&id=$2 [NC,L] RewriteRule ^([^/]*)/([0-9a-zA-Z_-]+)/([0-9]+)$ product_categories.php?cat=$2&id=$3 [NC,L] RewriteRule ^(.*)/(.*)/([0-9a-zA-Z_-]+)/([0-9]+)$ product_details.php?cat=$3&id=$4 [NC,L] RewriteRule ^([0-9]+)$ gallery.php?id=$1 [NC,L] I'm trying create urls like the following. www.example.com/product_name/1...

How can I implement this twbs-pagination


javascript,php,jquery,pagination
I am using this plugin to paginate my list items but I am confused about how to implement this to query to my table to pull and limit 10 or depending on my needs and display this inside in my <ul> tag. Here is my sample. Database.php class Database{ protected...

Redirect specific Url variables


php,.htaccess,mod-rewrite,redirect
My site used to generate URLs like this: /data.php?s=1432862823&type=basic I have modified the program so the new URLs generated are: /d.php?s=1432862823&t=basic Since some people have bookmarked the old URLs I want to write a Rewrite rule that will get them to the new url. I've not this so far: RewriteEngine...

mod_rewrite - force redirecting to rewritten URL


apache,.htaccess,mod-rewrite,redirect
I have following URL [1]: www.domain.com/?search=somequery which i want to redirect to [2] www.domain.com/search/somequery I am using following code in my .htaccess: Options +FollowSymLinks -MultiViews RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^search/(.*)$ /?search=$1 [L] Code above works kind of fine since server understands both URLs:...

htaccess errors after upgrading Apache from 2.2 to 2.4


apache,.htaccess
I use 3 hosting for my websites, all of them have the same rules in htaccess. One of the hosting was upgraded from Apache 2.2 to 2.4 and now I am getting errors spam and I don't know how to fix it without lossing the rule. [Mon Jun 15 19:38:33.189697...

Remove plus sign from url using .htaccess


php,regex,apache,.htaccess,mod-rewrite
My current url is: http://localhost/mywbsite/search/one+piece/149 I want to change link to like this http://localhost/mywbsite/search/one-piece/149 I have already .htaccess file with this code Options -MultiViews RewriteEngine On RewriteBase /indianrealitybytes/ RewriteCond %{THE_REQUEST} /search_advance\.php\?keywords=([^&]+)&f=([^\s&]+) [NC] RewriteRule ^ search/%1/%2? [R=301,L] RewriteRule ^search/([^/]+)/([^/]+)/?$ search_advance.php?keywords=$1&f=$2 [QSA,L,NC] I don't know where to change to remove plus(+) sign...

Codeigniter URL routing issues in .htaccess


php,apache,.htaccess,codeigniter-2
Before you mark it as duplicate FIY I have tried all solutions I could find on SO. The url is www.deltadigital.ca config file (if I use $config['base_url'] = 'http://www.deltadigital.ca' - it doesnt work at all) //$config['base_url'] = 'http://www.deltadigital.ca'; $root=(isset($_SERVER['HTTPS']) ? "https://" : "http://").$_SERVER['HTTP_HOST']; $root.= str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']); $config['base_url'] = $root;...

htaccess query string redirect not working correctly


.htaccess
I have a situation where I want to actually see the url variable even though the rest of my htaccess site uses readable URLS. The issue is that it is simply showing up as a page not found... This works... RewriteRule ^files/(.+)/from_all_files/$ pages/file.php?slug=$1&from=all-files This does not work RewriteRule ^files/(.+)?from=all-files$ pages/file.php?slug=$1&from=all-files...

Https rewrite needs fix when visitors enter www. at the beginning [closed]


php,.htaccess
I want to direct visitors to the https url, so with the below code if a visitor types domain.com he will go to the https://www.domain.com But if he types www.domain.com he will go to the https://www.www.domain.com How can I avoid this? RewriteEngine On RewriteCond %{HTTPS} !on RewriteRule (.*) https://www.%{HTTP_HOST}%{REQUEST_URI} ...

Force WWW when URL contains path using .htaccess


.htaccess,session,url,redirect
I'm having a problem with my URL and my sessions. I wish to have ALL website pages be forced to use www. As it looks like now, the website looks like this: www.example.com into www.example.com example.com into www.example.com www.example.com/example/ into www.example.com/example/ example.com/example into example.com/example (this is what's wrong) This is...

.htacces rewrite by cookie value


apache,.htaccess,mod-rewrite,cookies,url-rewriting
I have a website in 2 languages. I'm inserting the text for each language through php constants and I define the user language through a cookie (lang=es or lang=en). Now the base url in each language is www.webname.com/ but i want to rewrite it depending on the language. If the...

Openshift redirect to https using flask-base example


python,.htaccess,flask,openshift
I'm trying to run my flask based app on free gear on Openshift only on https. Following this - I have added the .htaccess file to the root of my repo but it seems to be ignored, as it is not redirecting. The article talks about a wsgi directory but...

Why same .htaccess commands working differently in localhost and server?


php,apache,.htaccess,url-rewriting
I have the following .htaccess command for redirection of php pages RewriteRule ^(.*)$ index.php/$1 [L] This code is working in localhost.It is not working in web server. But when code is slightly modified it works in server. RewriteRule ^(.*)$ index.php?/$1 [L] Why is this happening?...

Rewrite url not working in htaccess


php,apache,.htaccess,mod-rewrite,url-rewriting
I have website. I just want to rewrite url using .htaccess Here is the code which I want to rewrite: RewriteEngine On RewriteBase / RewriteCond %{QUERY_STRING} /search_data.php\?keywords=([^&]+)&f=([^\s&]+) [NC] RewriteRule ^/search_data.php/?$ /search/%1/%2? [R=301,L,NC] this the current url http://localhost/mywbsite/search_data.php?keywords=one+piece&f=149 I want to convert this to this http://localhost/mywbsite/search/one-piece/149 I tried above code but...

Unable to connect to your database server using the provided settings in Codeigniter


mysql,.htaccess,codeigniter
Actually I'm trying to configure my codeigniter live file to localhost. I have, created a database called test_bs then imported the tables Then change the base_url like $config['base_url']=http://localhost/gu_ci/'; and $config['index_page']='index.php'; in config.php And then did a change on database.php,Which contains $active_group = 'default'; $active_record = TRUE; $db['default']['hostname'] = 'localhost'; $db['default']['username']...

How to get range of 10 items from the arraylist in java? [on hold]


java,arrays,arraylist,pagination
I have a dynamic arraylist where the values are coming from the database. Let's say 85 records are selected from the database and inserted in to the database. Now I need to display those records in a pagination format with limit of 10 rows per page. How can I fetch...

redirect certain pages to its equivalent in another domain, otherwise redirect to its homepage


apache,.htaccess,rewrite,url-redirection
I want to use htaccess to redirect certain pages to its equivalent in another domain, other pages redirect to homepage. Like that: http://old-domain.com/certain-page redirected to: http://new-domain.com/certain-page http://old-domain.com/another-certain-page redirected to: http://new-domain.com/another-certain-page Only these pages will be redirected, otherwise, pages have to be redirected to the new domain home page. http://old-domain.com/non-certain-page redirected...

Rewrite non-dynamic pages using htaccess


apache,.htaccess,mod-rewrite
I've been banging my head since many hours on this and I am unable to come up with a solution. What I need to get done. domain.com/page.php => domain.com/page/ domain.com/category1-name1.php => domain.com/category1/name1/ domain.com/category2-name1.php => domain.com/category2/name1/ Details: I have couple of files with the following names & I want them to...

Excluding certain pages from being redirected to https


wordpress,.htaccess,redirect,https,http-redirect
I'm using the following rules on my WordPress website to: Redirect all http pages to https Redirect the careers page to http <IfModule mod_rewrite.c> RewriteEngine On # Go to https if not on careers RewriteCond %{SERVER_PORT} 80 RewriteCond %{REQUEST_URI} !^/careers$ [NC] RewriteRule ^(.*)$ https://www.mywebsite.com/$1 [R,L] # Go to http if...

Best way to block countries [on hold]


php,apache,.htaccess
I was requested to prevent access to a website. There are two ways I know I can choose - 1. At apache level (a tool like this: http://www.ip2location.com/blockvisitorsbycountry.aspx) which generates a long htaccess file with list of IP ranges. The other way I know of is using PHP (be it...

Filtering QUERY_STRING with back references in RewriteCond


php,regex,apache,.htaccess,backreference
I have a PHP script used to process images before displaying them on the web page. The query string has to be checked to reject all requests coming from external domains. If TLD is example.com http://example.com/process.php?img=somepath/images/imgX.png OK http://example.com/process.php?img=http://example.com/anotherpath/folder/images/imgX.png OK http://example.com/process.php?img=http://anotherdomain.com/images/someimg.jpg Rejected! This rewrite rules work on my test server: <IfModule...

Apache Regex How To Get This Value


php,regex,apache,.htaccess
I have a URI like this: http://example.com/demo/makemoney?matchtype=chancee&network=agagag&ifmobile=1&placement=nyc&adposition=111&copy=25&pid=123&zid=231&mid=234&cid=342&param1=zaleemm&param2=vatansvr I want to get makemoney and after "?" character values. In my .htaccess file write this rule: RewriteRule ^demo/(.*)?(.*)$ demo.php?utm_campaign=$1&$2 [L,NC] But only utm_campaign I get in $_GET super globals. What's true regex?...

Custom Loop Pagination in Wordpress


wordpress,pagination,custom-post-type
im using this custom loop within a wordpress page. It works great (although it has been simplified here). However, it displays 100's of search results on one page. Because it is a custom loop, i am struggling to get it to work with some pagination (ideally 10 per page). Has...

Htaccess rewrite URL with virtual directory and 2 variables


regex,apache,.htaccess,url,rewriting
its my URL... result.php?team=arsenal&player=ospina I want to like this mysite.com/virtualdirectory/arsenal/ospina.html I tried this code.. cant work.. Not Found RewriteRule ^(.*)/(.*)/(.*).html$ result.php?team=$2&player=$3 [L] The requested URL /subfolder/arsenal/ospina.html was not found on this server. Apache/2.2.8 (Win32) PHP/5.2.6 Server at localhost Port 80 Thanks for helps, Best regards!!...

Dissallow php execution for CSS folder with htaccess from parentfolder


php,apache,.htaccess
I have a question. I want to give one customer FTP access to the CSS folder of my webshop. I tried to prevent running PHP in this folder, but its not working. I think my problem is, that i dont want to add another .htaccess in the css folder. I...

Do 301 redirects work on urls that contain query strings?


.htaccess,http-status-code-301
I've searched for this but the answers I've found seem to be around rewriting URLs or for redirecting lots of pages in an entire section and look confusing (lots of regex). We need to add some 301 redirects and everything is working fine except for 13 URLs that contain query...

Silverstripe PaginatedList - How to display record numbers on current page?


pagination,silverstripe
In silverstripe PaginatedList we can display Page numbers like 'Showing 1 of 5 Pages'. How to display record number on each page for example "Showing 1-10 record of 100"

Apache htaccess redirect file


php,regex,apache,.htaccess,redirect
I want to redirect any request for file from my old website to the same file but with different url on my new website : www.oldwebsite.com/aaa/bbb/ccc/file.txt -> www.newwebsite.com/bbb/ccc/file.txt I have tried this solution on .htaccess file: RewriteEngine On RewriteRule ^(aaa/bbb/ccc/)(.*)$ http://newwebsite.com/bbb/ccc/$2 [R=301,L] but when I try with this url :...

.htaccess | Too many redirects


apache,.htaccess,mod-rewrite,redirect
I want to add a IP filter into my .htaccess file, but after I applied it, a too many redirects error will show. Content of .htaccess: RewriteEngine On RewriteCond %{HTTPS} off RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} RewriteCond %{HTTPS} on RewriteCond %{HTTP_HOST} ^[^.]+\.[^.]+$ RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [L,R=301] RewriteCond %{HTTPS} on RewriteCond %{REMOTE_ADDR} xxx.xxx.xxx.xxx...

Pretty URLs aren't working after upgrade to Mediawiki 1.24.2


.htaccess,ubuntu,mediawiki
So I am moving a Mediawiki site of mine to a new server. The version 1.20.3 worked fine on the old server running Ubuntu 12.04. However, when I copied everything over to my new server running Ubuntu 14.04 it didn't. So after messing with it for a while I decided...

Pattern matching in htaccess rewrite condition


apache,.htaccess,mod-rewrite,https
I have a rewrite condition in an .htaccess file which is used to 'not' force specific URLs to use a HTTPS connection but it's matching erroneously on other URLs at present, here's the rewrite rule... RewriteCond %{HTTPS} off RewriteCond !/go/ [NC] RewriteCond %{HTTP_HOST} ^app\.ihasco\.co\.uk [NC] RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] And...

htaccess redirect to subdomain based on query string


php,apache,.htaccess,redirect,joomla
I searched for similar questions but none of them was applicable to my situation. What I need to do is redirect from old url's that have specific query string: option=com_virtuemart to a subdomain : http://parts.domain.com Tried bunch of rules and conds but haven't achieved right redirection. It was always redirecting...

Redirect pages in Sub folder using .htaccess


.htaccess,url-rewriting
I have looked all over for the answer but can't seem to get any examples working so I need some help. I have a website built in PHP (Not using a framework). I have sub-pages in a folder called /some-work/ So the address to these sub pages is www.domain.co.uk/some-work/page I...

alert grails pagination current offset value


grails,pagination
I am using Grails 2.4.2. I have a list which is using pagination. When I mouse hover a number or next page icon it shows current offset number as tool tip. Can I alert this offset number or get my list's current page offset number?

Redirect 301 with wordpress articles from a domain to another


wordpress,.htaccess,redirect
my client changed his wordpress website to a new domain. I tried with the htaccess to redirect 301 the articles dynamicaly but it's not working. The URL format of articles are : /%year%/%monthnum%/%day%/%postname%/ I put this in htaccess but not working : redirect 301 /([0-9]*)/([0-9]*)/([0-9]*)/(.*)/ http://www.newdomain.com/$1/$2/$3/$4/ Can you help me...

Laravel 5 pagination with trailing slash redirect to 301


php,laravel,redirect,pagination,laravel-5
I'm using Laravel 5 and notice that the pagination is adding a trailing slash before the ?page=# and with that, it always redirect to a 301 page. http://example.com/news/articles/?page=2 will do a 301 redirect to http://example.com/news/articles?page=2 This is causing my pagination using ajax to slow down because it is having 2...

Page doesn't load after .htaccess redirect with parameters


php,.htaccess,url-rewriting
I recently hosted my website on 000webhost.com and once I hosted it, I logged in to check its working. When I click on a link such as message or profile that contains three parameters such as url, id and ref, the page gets redirected but the profile/message page doesn't load....

How to rewrite example.com/catelogue.php?page=3&cat1=fruit&cat2=apple with .htaccess


php,apache,.htaccess,mod-rewrite,url-rewriting
Can anyone help me with .htaccess rewrite url, I am new to it and stuck with this below problem i have this urls http://example.com/catelogue.php?page=3 http://example.com/catelogue.php?page=3&cat1=fruit&cat2=apple and i want this to be http://example.com/catelogue http://example.com/catelogue/fruit/apple Below is my .htaccess file, but here the problem is I have achieved this (example.com/catelogue/fruit/apple) but I...

.htaccess allow image to display directly


php,regex,apache,.htaccess,redirect
I have many files including images, php& js scripts and subfolders. I need to redirect to index.php for any uri using .htaccess. for example: www.example.com/test should be redirect to index.php But images should not be redirected to index.php. Instead it should be printed directly in browser. For example: www.example.com/sample.jpg should...

.htaccess Mod_Rewrite inconsistent


php,apache,.htaccess,mod-rewrite
Here is my .htaccess file: RewriteEngine On #Working rules: RewriteRule ^privacy$ privacy.php [L] RewriteRule ^terms$ terms.php [L] RewriteRule ^team$ team.php [L] RewriteRule ^candidates$ candidates.php [L] RewriteRule ^clients$ clients.php [L] #Not working rules: RewriteRule ^article/([^/]*).*$ article.php?id=$1 [L] RewriteRule ^job/([^/]*).*$ job.php?id=$1 [L] RewriteRule ^contact/([^/]*).*$ contact.php?location=$1 [L] The top rules are all working...

Redirection loop (URL rewriting)


regex,apache,.htaccess,mod-rewrite,rewriting
I'm trying to rewrite my website URLs. I have: http:// website.com/v2/message.php?ID2=123 I want: http:// website.com/v2/message-123.php I tried something in my htaccess but I've a redirection loop :'( Here is my .htaccess: RewriteCond %{QUERY_STRING} ^ID2=([0-9]+)$ RewriteRule message.php? http://website.com/v2/message-%1.php? [L,R=301] Can someone help me with this?...

When I click to the next page on pagination,it goes to 404 error in codeigniter


php,codeigniter,pagination
In my News.phpcontroller,i'm having the below code: public function index() { $data['title'] = 'Database Details'; $config = array(); $config['base_url'] = base_url("news/index"); $config['total_rows'] = $this->news_model->record_count(); $config['per_page'] = 5; $config['uri_segment'] = 3; //$config['use_page_numbers'] = TRUE; // $config['page_query_string'] = TRUE; $choice = $config["total_rows"] / $config["per_page"]; $config["num_links"] = round($choice); $this->pagination->initialize($config); $page =...

Htaccess regex: exclude REQUEST_URI


regex,apache,.htaccess,mod-rewrite,redirect
I really tried everything, the tool htaccess tester says that it's ok, but it's not really working. I want to redirect a subdomain to the main domain only if the REQUEST_URI doesn't start with 3 specific strings. I tried without success with: RewriteCond %{HTTP_HOST} ^sub.example.com$ [NC] RewriteCond %{REQUEST_URI} !(aaa|bbb|ccc) RewriteCond...

Make dynamic links (with ?) return error 404 not found


apache,.htaccess,dynamic,hyperlink,http-status-code-404
Using .htaccess (are there any other solutions?) is there a way to make all dynamic links (links containing the sign ?) of a site return a 404 not found response header? For example: http://www.example.com/?bla_bla - will return 404 http://www.example.com/test/index.html?no_redirect=true - will return 404...

after using mod_rewrite link are not found


php,.htaccess,mod-rewrite
I was changed my url from http://example.com/admin/courses.php?id=1001 to http://example.com/articles/1001 usig this code RewriteEngine On RewriteRule articles/([A-Za-z0-9-]+)/?$ admin/courses.php?id=$1 [NC,L] but after changing the url, all the css, images, js link of course.php page is automatically change from http://example.com/admin/css/style.css to http://example.com/articles/css/style.css I need to help...

URL Rewriting in php CodeIgniter using .htaccess


php,apache,.htaccess,codeigniter,mod-rewrite
I am working on a project in which url Rewriting was done. Here is the link of the old uri http://www.mysite.pk/jobs/search/faisalabad/all-cats But now in the new url I have changed it to http://www.mysite.pk/jobs/pakistan/faisalabad/all-cats what I want to do is to change the redirect all the url's whcih have http://www.mysite.pk/jobs/search/ search...

mod-rewrite to remove a folder


apache,.htaccess,mod-rewrite
I have the following URL http://www.example.com/folder1/folder2/file.php I want to redirect it to http://www.example.com/demo/folder1/file.php I tried this, but it does not work: RewriteCond %{HTTP_HOST} www.example.com RewriteCond %{REQUEST_URI} ^folder RewriteRule /demo/folder(.*) /folder1/folder2/$1 ...

Allow space and other special characters in htaccess url rewrite


php,regex,apache,.htaccess,mod-rewrite
Hi everyone i have this URL: orderprod_cntr/147/ok2%20-%20val1%20val2%20val3%20val4 When ever i open this URL i get 404 error. The htaccess rule that i am using at present is: RewriteRule orderprod_cntr/([-\w]+)/([-\w]+)/?$ controller/orderprod_cntr.php?id1=$1&id2=$2 [L] The error is occurring due to %20 in the URL, without it works fine. Please tell me the correct...